Apache httpd server 2.4.10 and PHP-FPM 5.6 in Fedora 21
+
Par Remi le vendredi 1 août 2014, 21:31 - HowTo - Lien permanent
Since the update in Fedora 21 of httpd version 2.4.10 and php 5.6.0RC3, you can avoid using mod_php. php-fpm works "out of the box", with default provided configuration.
Installation:
# yum remove php
# yum install php-fpm httpd
Services:
# systemctl start php-fpm.service
# systemctl start httpd.service
Test
# echo '<?php phpinfo()' >/var/www/html/info.php
URL: http://localhost/info.php
You should see the message : Server API: FPM/FastCGI
Configuration
The default provided configuration now work in Fedora 21.
You can use the same in Fedora 19 and 20, applying some change to your PHP configuration file /etc/httpd/conf.d/php.conf
Disable the php_* directives, when mod_php is not loaded:
# mod_php options
<IfModule mod_php5.c>
...
php_value session.save_handler "files"
php_value session.save_path "/var/lib/php/session"
php_value soap.wsdl_cache_dir "/var/lib/php/wsdlcache"
</IfModule>
Enable redirect the execution of php scripts to php-fpm service:
# Redirect to local php-fpm if mod_php is not available
<IfModule !mod_php5.c>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</IfModule>
Apache httpd server optimisation
Time to leave the prefork MPM in /etc/httpd/conf.modules.d/00-mpm.conf
LoadModule mpm_event_module modules/mod_mpm_event.so
For packagers
php-fpm only pull httpd-filesystem, for user creation and configuration directory ownership and can still be used without httpd, for example with nginx. Despite I still think than Apache httpd server still the best server to package web applications, mostly as it allows to drop a configuration file, per application, with global alias.
I encourage you to test your applications with this configuration, especially to ensure than all php_* directives are properly conditionalized..
Next step will be to drop the dependency on mod_php and give back the choice to our users.
Conclusion
This feature finally drop the difficulty to use PHP-FPM and other Apache MPM. A pity that it is not available in httpd version provided by RHEL/CentOS-7 or by RHSCL 1.1.
Commentaires
Also see the comments on the old entry PHP-FPM and HTTPD 2.4 improvement