duanmie9682
duanmie9682
2014-04-11 18:05
采纳率: 100%
浏览 120
已采纳

如何在phpfarm php安装上安装pthreads

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条回答 默认 最新

  • duanhuizhe6767
    duanhuizhe6767 2014-04-11 18:53
    已采纳

    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 ...

    点赞 评论

相关推荐