9

I am trying to install pthreads by using

pecl install pthreads

But I got this error during the installation

configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled

I have searched for this error. It seems that I have to install a new version of PHP with ZTS enabled. Is there any simpler ways to recompile with ZTS enabled instead of reinstalling PHP?

1 Answer 1

11

Here is the quoted answer from a Digital Ocean community comment:

ZTS support is a configure time option and can not be enabled at run time. You'll need to build php yourself with the --enable-maintainer-zts flag in order to enable it.

One way to do this is to modify the existing package and rebuild it. First we'll need to install and download a few things:

Install the build dependencies:

sudo apt-get build-dep php5

Install the developer tools:

sudo apt-get install devscripts

Download the source:

apt-get source php5

Now enter the source directory and edit the debian/rules file:

cd php5-5.5.9+dfsg/    # The version will be different depending on the Ubuntu release
nano debian/rules

Find the section starting with COMMON_CONFIG=--build=$(DEB_BUILD_GNU_TYPE) \ and add the following configure flags:

        --enable-maintainer-zts \
        --enable-pthreads \

Then we want to bump the version number for the package, so that it is higher than the version of PHP in the repository. Run dch -i and create a new changelog entry:

php5 (5.5.9+dfsg-1ubuntu4.5+zts1) trusty; urgency=medium

  * Rebuild with ZTS support.

 -- You <doesnt@matter.com>  Mon, 10 Nov 2014 13:14:32 -0500

Now the package can be built using the command:

DEB_BUILD_OPTIONS=nocheck debuild

This will take quite awhile and will also require some memory. If you're on a 512mb server, you'll probably need to add some swap.

It will produce a number of packages in the parent directory:

cd ..
ls *deb

You can now install the individual packages with sudo dpkg -i pakage_name.deb or all of them with sudo dpkg -i *deb

4
  • Thanks for this. It has been very helpful. To anyone reading this in the future, this method works for php 7 as well. Just make sure you run sudo apt-get install build-deps php7.0 Oct 10, 2016 at 21:18
  • 1
    It actually does't, Native Coder. This is the exit of the command: sudo apt-get build-dep php7.0 Lendo listas de pacotes... Pronto E: Impossível encontrar um pacote fonte para php7.0 Nov 20, 2016 at 0:37
  • @ViniciusDias what does your error message mean in English? I have issues with rebuilding PHP too.
    – DBX12
    Jan 18, 2018 at 6:51
  • It means Reading package lists... Done E: Impossible to find a source package for php7.0 Jan 21, 2018 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.