HostOnNet Blog

php-fpm use socket

By default php-fpm listen on tcp port 9000.

It is better to use socket instead of tcp as it is less overhead.

To change, edit file

vi /etc/php/7.0/fpm/pool.d/www.conf

Find

listen = 127.0.0.1:9000

Replace with

listen = /var/run/php-fpm.sock

Now edit nginx config.

vi /etc/nginx/sites-enabled/yoursite.conf

Find

fastcgi_pass 127.0.0.1:9000;

replace with

fastcgi_pass  unix:/var/run/php-fpm.sock;

Now restart nginx and php-fpm

service nginx restart
service php7.0-fpm restart

Posted in Linux