Configuring IPtables for PHP-FPM

So, I have a CentOS server running Nginx and now I want to start Nginx with PHP-FPM. It defaults to port 9000, but I will use 9001. I need to know how to open port 9001 for loopback in my iptables. Which of the following is correct, are they the same or both are incorrect? Any help would be appreciated, thanks :)

iptables -A INPUT -p tcp -s --dport 9001 -j ACCEPT


iptables -A INPUT -i lo -dport 9001 -j ACCEPT


source to share

1 answer

You don't need to open a firewall to connect to localhost, as it doesn't have to be a firewall anyway (as a general rule of thumb).

But I would suggest using the advice above to use sockets instead.

Modify / etc / php5 / fpm / php5-fpm.conf and search for these two lines:

listen = /var/run/php5-fpm.sock
;listen =


Comment out port one and uncomment sock one - restart php-fpm :)



All Articles