Leave a Comment

Using /var/run/php5-fpm.sock isn't required and you can swap back over to TCP quickly and easily.

First thing we need to do is login to SSH as root or your sudo user and then navigate to:

cd /etc/php/5.6/fpm/pool.d

You'll see a file named www.conf`. That's the file we need to modify, so go ahead and open it:

nano www.conf

Now we need to find the line that looks like this:

listen = /run/php/php5.6-fpm.sock

Change that line to read:

listen = 127.0.0.1:9000

Then restart php-fpm using:

service php5.6-fpm restart

The only time this won't work is if NGINX is configured to route PHP requests to another port, such as 9001, 9002, etc. This is possible, so if the above doesn't work, don't worry, we just need to do a little more investigating.

You'd want to browse over to /etc/nginx and look in sites-available for your NGINX server block configuration file, open it and find the location block that handles your PHP requests and see what the port is there.

cd /etc/nginx/sites-available

Once you have the port that is set in one of the configuration files for your site, simply copy that port to the above PHP-FPM configuration. In most cases, 9000 is the default, but in rare cases, some pre-configurations use another.

Hello I read quite often on the internet that listen = /run/php/php5.6-fpm.sock needs to be changed for listen = 127.0.0.1:9000. I did not do that and everything seems to work well. Yet, people tend to say that is it not performant to listen to the sock. Why ? Is it true ?

To be clear, you don't have to use TCP instead of sockets -- sockets work just fine, though you often need to fine-tune sysctl parameters (when using sockets) as your site grows and traffic increases so that you don't hit a ceiling.

When using sockets and TCP, you still need to setup a new one for each site you host, so each site would require a socket or different TCP port. For example:

listen = 127.0.0.1:9000

listen = 127.0.0.1:9001

listen = 127.0.0.1:9003

or

listen = /run/php/php5.6-fpm.sock

listen = /run/php/php5.6-fpm02.sock

listen = /run/php/php5.6-fpm03.sock

With sockets, there's also a few other configuration variables in the ./pool.d config file that needs to be modified to ensure they are running with proper user:group permissions.