Here is how you can switch PHP-FPM to listen on a unix socket rather than a TCP socket. This guide assumes you have already installed a LEMP stack as shown in Install LEMP on Centos.
Switch PHP-FPM Listen On Unix Socket
Step 1. First, edit the file at /etc/php-fpm.d/www.conf and find this block:
; The address on which to accept FastCGI requests. ; Valid syntaxes are: ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on ; a specific port; ; 'port' - to listen on a TCP socket to all addresses on a ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. ;listen = 127.0.0.1:9000 listen = /var/run/php5-fpm.sock
Step 2. Next, let’s create a file at /etc/nginx/conf.d/ named php5-fpm.conf:
upstream php5-fpm-sock { server unix:/var/run/php5-fpm.sock; }
Step 3. Open Nginx virtual-host config file(s), In our Nginx server config we’ll also have to change where to pass PHP requests:
#fastcgi_pass 127.0.0.1:9000; fastcgi_pass php5-fpm-sock;
Step 4. Reload php-fpm and nginx.
service php-fpm restart service nginx restart
Nginx Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “Nginx Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!