1

I'm looking to switch a Fedora server running Apache from prefork to worker.

Everything seems to be fine except the php libraries for Mongo and Memcache. Has anyone had any success getting these to work with the httpd worker mpm?

Note that I installed memcache and mongo like this:

yum install php-pecl-memcache php-pecl-mongo

On a whim, I tried copying the .so's from /usr/lib64/php/modules/ to /usr/lib64/php-zts/modules/, but I got these errors:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php-zts/modules/memcache.so' - /usr/lib64/php-zts/modules/memcache.so: undefined symbol: basic_globals in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php-zts/modules/mongo.so' - /usr/lib64/php-zts/modules/mongo.so: undefined symbol: core_globals in Unknown on line 0

1 Answer 1

2

You cannot just copy modules from /usr/lib64/php/modules/ to /usr/lib64/php-zts/modules/ — ZTS (threaded) and non-ZTS builds of PHP have different module ABI.

Apparently the php-pecl-memcache package for Fedora 18 and even the Rawhide package are built without ZTS support, so they are not usable with mod_php in a threaded Apache MPM.

You have several options here:

  1. According to the recommendation in the PHP FAQ, the most reliable way to use PHP together with a threaded Apache MPM is the FastCGI mode (e.g., with php-fpm), so that PHP will run in separate single-threaded processes. This way you can use all available PHP extensions — even those which use non-threadsafe libraries and cannot work in a multithreaded process at all.

  2. If you really need to use mod_php with a threaded MPM, you can use third-party packages (like this) which are built with php-zts support (notice that /usr/lib64/php-zts/modules/memcache.so is present in the file list).

  3. If you cannot find a ready-made binary package with php-zts support for a PHP extension you need, you can try to rebuild the package yourself, but even this may not be possible if the extension in question does not have ZTS support in its code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .