From ArchWiki
Jump to navigation Jump to search

modified LAMP sections

Using php5 with php-fpm, mod_proxy_fcgi and mod_proxy_handler

Note: Unlike the widespread setup with ProxyPass, the proxy configuration with mod_proxy_handler and SetHandler respects other Apache directices like DirectoryIndex. This ensures a better compatibility with software designed for libphp5, mod_fastcgi and mod_fcgid. If you still want to try ProxyPass, experiment with a line like this:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://$1
  • Verify the values of these settings in /etc/php/php-fpm.conf:
listen = /run/php-fpm/php-fpm.sock
listen.owner = http = http
listen.mode = 0660
  • Append following to /etc/httpd/conf/httpd.conf:
LoadModule proxy_handler_module modules/
<Proxy "unix:/run/php-fpm/php-fpm.sock|fcgi://php-fpm.local/">
    # Register php-fpm unix socket with a fictional local domain
    # we must use ProxySet, so set min=0 which is the default anyways 
    ProxySet min=0
<FilesMatch \.php$>
    # Send .php files to the unix socket
    SetHandler "proxy:fcgi://php-fpm.local/"
<IfModule dir_module>
    DirectoryIndex index.php index.html
  • Make sure /etc/php/php.ini has the directive enabled:
# systemctl restart httpd.service php-fpm.service