Installing php-fpm apache 2.4.6 on Centos 7

I am trying to use php-fpm as I have heard it can increase performance on my webserver, and it appears to be working.. but it doesn't look like it has speeded anything up.

I ran through the following steps.

  • Installed php-fpm using yum
  • Configured the php-fpm to use a unix socket and set the [www] listen to apache
  • Renamed 10-php.conf to 10-php.conf.disabled
  • Switched mpm from mpm_prefork_module to mpm_event_module
  • Added the following to all my vhosts underneath the Directory setting:

    # php-fpm
    <FilesMatch "\.php$">
      SetHandler  "proxy:unix:/var/run/php-fpm/php-fpm.sock|fcgi://www/"
    </FilesMatch>
  • Restarted/Started everything and enabled php-fpm on boot

I was a bit confused about mod_fcgi, mod_fastcgi and mod_php but haven't changed any of these (other than renaming 10-php.conf). I read something about mod_proxy_fcgi being the modern standard but again haven't explicitly installed or enabled it.

Is this the correct setup, or am I missing something to get any benefit?


This solution doesn't use UNIX sockets (it listens on port 9000), but I give this answer for others who may be looking for a means to install PHP7-FPM on CentOS in an easy manner.

Step 1: Set Up PHP-FPM Daemon

Configure your Software Collections repository, then:

yum install rh-php70 rh-php70-php-fpm
systemctl enable rh-php70-php-fpm
systemctl daemon-reload
systemctl start rh-php70-php-fpm
  • Config is under /etc/opt/rh/rh-php70
  • Logs are under /var/opt/rh/rh-php70/log/php-fpm/www-error.log
  • systemd links /etc/systemd/system/multi-user.target.wants/rh-php70-php-fpm.service to /usr/lib/systemd/system/rh-php70-php-fpm.service
  • The executable lives at /opt/rh/rh-php70/root/usr/sbin/php-fpm

Step 2: Configure Apache FastCGI

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/$1

Further reading.