1

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?

1

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.

0

If you are optimizing anything you should have a metric you're looking at. Make some measurement, there're a lot of tools for that, like ab, siege. jmeter.

Get some results and compare different configuration to see which one is better for you.

1
  • I was looking at response time and possibly memory use, neither of which showed any obvious improvement.. I was asking in case I missed a part of the set-up.
    – Arth
    Nov 9 '15 at 11:42
-2

Please have a look in php-fpm config directory where you need to optimize according to your server resource checkout your configuration.
Reerence:
https://serversforhackers.com/video/php-fpm-process-management
http://php.net/manual/en/install.fpm.configuration.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.