Question

Enable ZTS Support on Ubuntu 14.04

  • Posted November 10, 2014

Hi, i’ve installed everything that regards PHP from the repository. I’ve installed php5-dev package and all other dependencies to run pthreads on my droplet. I don’t understand how to enable the ZTS on it…what should i do? Do i have to download PHP5 from another source? Thanks.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

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

Hi I have the same error

php_error_docref(NULL, E_ERROR, "Timezone initialization failed");

and I have run

sudo dpkg-reconfigure tzdata

but php not compile, so, do you have any comments?

peteinba, i fixed this problem

sudo dpkg-reconfigure tzdata

you need to choose your local timezone and retry all.

This comment has been deleted