3

I have a setup with two small servers running nginx serving as proxy and a number of Apache+mod_php beefy servers. I am thinking on going over to PHP-FPM. Can I configure nginx to use a number of FastCGI servers? Or PHP-FPM itself to use workers on different machines? Or do I need to run nginx on the workers?

chx
  • 1,705
  • 2
  • 16
  • 25

2 Answers2

7

no you can run 1 nginx machine and many php-fpm machines.

upstream php {
  server 10.0.0.1:9000;
  server 10.0.0.2:9000;
  server 10.0.0.3:9000;
}

Then in your locaction

fastcgi_pass php;
Mike
  • 22,310
  • 7
  • 56
  • 79
1

A complement to Mike's answer.

Check this vulnerability that can arise when you have nginx and PHP-FPM in different servers. The bottom line is: don't allow users to upload content to your public directory.

ML--
  • 335
  • 1
  • 4
  • 11
  • this got fixed in php >=5.3.9 [issue](https://disq.us/url?url=https%3A%2F%2Fbugs.php.net%2Fbug.php%3Fid%3D55181%3AaQuKoujCOhGb9OxfGdB83t6aAgc&cuid=1200067) – JohannesM Oct 08 '21 at 11:47