, , ,

PHP-FPM RedHat7 CentOS7 Apache 2.4

Avant de passer en PHP-FPM nous avions ✈ :

/etc/httpd/conf.d/php.conf

#
# Cause the PHP interpreter to handle files with a .php extension.
#
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
 
#
# Allow php to handle Multiviews
#
AddType text/html .php
 
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
 
#
# Uncomment the following lines to allow PHP to pretty-print .phps
# files as PHP source code:
#
#<FilesMatch \.phps$>
#    SetHandler application/x-httpd-php-source
#</FilesMatch>
 
#
# Apache specific PHP configuration options
# those can be override in each configured vhost
#
php_value session.save_handler "files"
php_value session.save_path    "/var/lib/php/session"
yum remove php
rm /etc/httpd/conf.d/php.conf
yum install php-fpm

Avec FPM

/etc/httpd/conf.d/php-fpm.conf

#
# PHP-FPM avec le compte php-monsiteweb (car 127.0.0.1:9001)
#
<FilesMatch \.php$>
    #SetHandler application/x-httpd-php
 
    # 2.4.10+ can proxy to unix socket
    # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
 
    # Else we can just use a tcp socket:
    SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
 
#
# Allow php to handle Multiviews
#
AddType text/html .php
 
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

/etc/php-fpm.d/monsiteweb.conf

[monsiteweb]
#listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9001
 
listen.allowed_clients = 127.0.0.1
 
user  = php-monsiteweb
group = php-monsiteweb
 
#pm = dynamic
pm = ondemand
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
 
# Pour debug
#catch_workers_output = yes
#php_flag[display_errors] = on
#php_admin_flag[log_errors] = on
#request_slowlog_timeout = 10s
#slowlog = /var/log/php-fpm/www-slow.log
 
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
 
php_value[session.save_handler] = files
# Doit être accessible en écriture par l'utilisateur PHP-FPM (définie dans ce fichier "user = ")
php_value[session.save_path] = /var/lib/php/session/php-monsiteweb
 
php_value[date.timezone] = "Europe/Paris"
 
# A ajuster
php_value[memory_limit] = 64M
php_value[post_max_size] = 10M
php_value[max_execution_time] = 60
php_value[max_input_time] = 60
adduser --system --home /var/www/monsiteweb/ php-monsiteweb
mkdir /var/lib/php/session/php-monsiteweb
chown -R php-monsiteweb:php-monsiteweb /var/lib/php/session/php-monsiteweb
systemctl enable php-fpm.service
systemctl restart php-fpm.service
systemctl status php-fpm.service