0

I have a PHP5 application which is served by an Apache2 server. I want to use the mpm_worker module which is not available if PHP is not thread-safe. So, I compiled PHP with the appropriate flags. This output confirms my PHP installation is thread-safe :

$ php -i | grep Thread
Thread Safety => enabled

Great! To create the link between Apache and PHP I activate the php5 module (a2enmod php5). The file which is used (libphp5.so) is installed by the package libapache2-mod-php5. However, on their page, they say:

Please note that this package ONLY works with Apache's prefork MPM, as it is not compiled thread-safe.

Does it mean that between my threaded Apache and thread-safe PHP stands libphp5.so which is not thread-safe? Thus making mpm_worker not available.

I thought to compile this file, like I did with PHP, to make it thread-safe. I didn't find any topics about it. I'd be glad to have any advice that would help my case.

When I look at phpinfo(), I can see that the version (PHP Version 5.6.30-0+deb8u1) does not match with the one I compiled (PHP 5.6.31). And that Thread Safety is shown as disabled. It's like it is using another PHP installation. Here's the PHP packages currently installed:

$ apt list --installed | grep php
libapache2-mod-php5/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed]
libphp5-embed/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed]
php5-cli/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed,automatic]
php5-common/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed,automatic]
php5-fpm/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed]
php5-json/oldstable,now 1.3.6-1 amd64 [installed,automatic]
php5-mysql/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed]
php5-readline/oldstable,oldstable,now 5.6.30+dfsg-0+deb8u1 amd64 [installed,automatic]
David Guyon
  • 2,759
  • 1
  • 28
  • 40

1 Answers1

0

There are other threads that explain your situation pretty well. For example here.

To sum it up: There are two ways to configure your apache regarding PHP.

  1. Using a standalone PHP. You compiled that on your own. Apache can connect to that. You can understand it as another server on your machine.
  2. Directly include PHP in your apache. That is mod_php. It is a standalone PHP installation which is NOT thread safe.

To solve your problem reconfigure apache to use your standalone PHP. It is more complex but might give you some speed depending on your use case.

schlicki
  • 374
  • 4
  • 14