2

Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.

The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.

Options:

1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..

2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.

3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?

4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)

A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.

So what gives with php, php-cli and the phpfarm?

1 Answer 1

4

I'm not sure about phpfarm, but do know of another solution ...

Multi

A tool for maintaining multiple installations of PHP in multiple configurations

https://github.com/datingvip/multi

This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.

In addition, because I wrote it, it will install pthreads for you.

git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi

The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.

Look at php.defaults for configuration options and adjust before building

Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that

sudo apt-get install library-dev

Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.

Once the build is complete

source /path/to/multi/php.env 5.5.10

Note: multi will always install pthreads for any zts version automatically

I hope that gets you somewhere ...

5
  • This looks like a nice solution, but I am failing towards the end of the build process. There is no notice of any library missing. I get: Installing PHPUnit and DBUnit for 5.5.10 zts debug from PEAR: ..(the next 6 lines produce: No such file or directory) Installing uopz for 5.5.10 zts debug from PECL ..(two more lines produce: No such file or directory, and then).. Failed to install uopz for 5.5.10 zts debug from PECL
    – Ricalsin
    Apr 12, 2014 at 21:58
  • BTW, the core php build does complete. I can run source php.env 5.5.10 and it will show expected results. And php -i | grep zts shows _SERVER["PHP_ZTS"] => zts. But nothing shows when grepping for pthread. Both /opt/php/5.5.10/zts/debug/bin/pear and /opt/php/5.5.10/zts/debug/bin/pecl are non-existent.
    – Ricalsin
    Apr 13, 2014 at 0:16
  • 1
    That sounds like an intermittent pear connection problem, I experienced this yesterday too, you might need to clean out /tmp/pear.* directories (ls /tmp, names will be obvious) ... do post an issue on github if you are still stuck ... Apr 13, 2014 at 8:27
  • Joe fixed this issue. Thanks for helping programmers understand that php can - in fact - safely work in a multi-threaded environment.
    – Ricalsin
    Apr 14, 2014 at 16:45
  • Once I run "source /usr/src/multi/php.env 5.5.10". My output returns this, I am unsure how to fix that. "Could not find /opt/php/5.5.10/zts/debug/bin" May 13, 2015 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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