Search code examples
phplinuxnginxfpm

Nginx installation with PHP


I have installed nginx and PHP into my machine. I want to know the difference between these to configuration when using PHP-fpm.

> fastcgi_pass    127.0.0.1:9000; 
            or  
>fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

which configuration is good for production servers, what is the benefit, what is the difference between the two configs?


Solution

  • fastcgi_pass 127.0.0.1:9000; is a TCP connection.

    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; is a unix socket connection.

    Both are suitable for production use, TCP allows you to connect via IP on an arbitrary port. The socket is filesystem based.

    If you have a web server and php running on separate servers then the TCP approach would be the way to go. If they're on the same server, the socket configuration would be better . Sockets run faster due to not having the TCP overhead.