Dynamically configure PHP for thread safety --enable-maintainer-zts, or use yum to install pthreads?

14,925

Solution 1

ZTS availability is determined during compile time, so no - you can't dynamically enable and/or disable it.

It is possible that you could install pThreads via yum or another package manager depending on your distro, but note that "possible" doesn't necessarily mean that it is an available option in your case. That depends on wether your software repository has such a package available, with a dependancy on another PHP build that has ZTS enabled. I highly doubt that this would be the case.

Solution 2

Unfortunately, package maintainers of CLI do not enable thread safety in most unix packages. It is sometimes enabled for worker mpm apache, but does not always include a full build environment ( such that pecl will not work ).

In short, there is no way of enabling ZTS at runtime, it is a build time option that makes changes to the build simply not possible after compilation of the sources.

However, it is not very hard to install a copy for yourself.

The path you take depends much on your experience with your distro and your intended usage.

Should you wish to overwrite your system installation with a thread safe version, there's some info http://pthreads.org/building

Should you wish to build an isolated installation, some information can be found on the building page at pthreads.org, additionally, I have been experimenting with RPM's, http://github.com/krakjoe/spex contains an rpmbuild file that will roll a copy of master and master pthreads into /opt/php-pthreads with the complete build environment, includes and all the bells and whistles, no apache support in the rpmbuild version because it would make it more complex and huge, it does include fpm ( also supported ).

You're the first person I have come across that I could actually advise to use the rpmbuild, on account of you can then keep the RPM for other VM's and only have to go through this once (until the next update anyway), the disadvantage of this is, it uses bleeding edge code from PHP, which is currently in beta...

Hopefully that gets you going :)

Share:
14,925
Dan
Author by

Dan

Long time software developer, focusing on building web front end and back end systems, as well as database systems

Updated on September 15, 2022

Comments

  • Dan
    Dan over 1 year

    Is there a way to enable thread safety in PHP without recompiling, or to use YUM to do this?

    I am trying to install pthreads and it requires PHP to have been compiled with --enable-maintainer-zts. However, I do not with to recompile because I would like to manage my PHP stack using yum. I am currently using the REMI repo. I notice there is a package php-zts, however, there is not one available for my PHP version of 4.4 and I cannot find a source RPM for php-zts.

    Is there a way I can use yum and enable thread safety in PHP, so I can install pThread by using

    #pecl install channel://pecl.php.net/pthreads-0.0.42
    
    downloading pthreads-0.0.42.tgz ...
    Starting to download pthreads-0.0.42.tgz (53,755 bytes)
    .............done: 53,755 bytes
    33 source files, building
    running: phpize
    Configuring for:
    PHP Api Version:         20100412
    Zend Module Api No:      20100525
    Zend Extension Api No:   220100525
    building in /var/tmp/pear-build-rootkThpG6/pthreads-0.0.42
    running: /var/tmp/pthreads/configure
    
    ...
    
    checking whether to enable Threading API... yes, shared
    checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
    ERROR: `/var/tmp/pthreads/configure' failed
    

    As you can see it fails, above, because PHP doesn't have ZTS enabled.