Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring IPtables for PHP-FPM

So I have a CentOS server with Nginx and now want to run Nginx with PHP-FPM. By default it's configured to port 9000 but I'm going to use 9001. I need to know how to open port 9001 for loopback in my iptables. Which of the following are correct, are they the same, or both wrong? Any help will be appreciated, thanks :)

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

or

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

like image 432
Jukodan Avatar asked Jan 28 '26 18:01

Jukodan


1 Answers

You shouldn't need to open the firewall to connect to localhost, as it shouldn't be firewalled anyway (as a general rule).

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

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

listen = /var/run/php5-fpm.sock
;listen = 127.0.0.1:9000

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

like image 125
Gareth Davies Avatar answered Jan 30 '26 09:01

Gareth Davies



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!