After an upgrade to PHP 8, I can only use non-threaded PHP instead of threaded (ZTS) PHP.
The server is CentOS 7, running Apache. The Server API is Apache 2.0 Handler. I used Remi's RMP Repository Configuration Wizard to upgrade PHP from 7.4 to 8.2.4. After the upgrade to PHP 8, Apache was running with threading enabled, but would only load the non-threaded PHP module and failed.
I see both two PHP executables: php and zts-php. I cannot find the threaded libphp7-zts.so module on the server. It appears that thread-safe php is installed, but Apache cannot find or load it.
Prior to the upgrade, PHP ran threaded. Info.php reported Thread Safety Enabled and included the /etc/php-zts.d directory. After the upgrade, PHP would not load. The info.php page just displayed white. php -i
shows that it's including /etc/php.d for additional .ini files. And apachectl -M
results did not include php.
I checked /etc/httpd/conf.modules.d/20-php.conf. It contained
Load Module php_module modules/libphp.so.
Prior to the upgrade the Apache php.conf file had two directives:
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
<IfModule !prefork.c>
LoadModule php7_module modules/libphp7-zts.so
</IfModule>
I updated the conf file to skip the IfModule parts and just use LoadModule php_module modules/libphp.so
. After that, I got an Apache error:
Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
I then updated the /etc/httpd/conf.modules.d/00-mpm.conf file to enable the prefork MPM module.
- comment out:
LoadModule mpm_event_module modules/mod_mpm_event.so
- uncomment:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
After this, info.php loaded. The php application runs.
Did I fail to include something in my yum installation? I installed php-cli and others (php-pdo, php-mysql, php-gd, etc.) to support the application.
Can I expect a performance penalty because of the threaded/non-threaded change?
I have 4 servers to update, production and development for two different applications. I've had the same issue on both development servers. I'd like to be able to run them threaded as they have been--just because change is scary and this is out of my normal work. If not, I'd like to learn what's happening here. I have read articles about compiling PHP to make it thread safe; I don't want to try that. If there is another way or if the non-threaded setup will work.