11

I have searched for an answer but cannot seem to find anything substantial related to this question.

Should one use mod_proxy_fcgi or mod_fastcgi with php-fpm on Apache2.4?

Are there any differences in terms of security and performance? Any recommendations?

Thanks in advance for any help.

smonff
  • 346
  • 2
  • 5
  • 15
Reuben Debattista
  • 113
  • 1
  • 2
  • 5

1 Answers1

14

mod_proxy_fcgi, which is newly available in Apache 2.4, is just for this type of use case. The Apache wiki entry for PHP-FPM has some good guidance to get started.

The mod_proxy_fcgi documentation also includes specific examples for setting up PHP-FPM and the PHP documentation also has helpful information.

On the other hand, mod_fastcgi is notoriously difficult to set up and a memory hog. Additionally, mod_fcgi doesn’t support spawned CGI servers. Because PHP-FPM is managed by itself, not by Apache, mod_fcgi isn’t the best choice.

Josip Rodin
  • 1,695
  • 13
  • 18
Colt
  • 2,029
  • 6
  • 21
  • 27
  • This explains why nothing was working when I attempted to set up mod_proxy_fcgi, I have Apache2.4.7 and a habit of using unix sockets. :) Any comments on performance? I know mod_fastcgi uses memory but is it faster? – Reuben Debattista Jun 10 '16 at 09:10
  • speed should not be an issue, although using sockets is probably more efficient; probably more important to be able to spawn PHP-FPM processes – Colt Jun 10 '16 at 09:24
  • So I will be sticking to mod_fastcgi because it seems the more logical choice. Thank you very much for your answer. – Reuben Debattista Jun 10 '16 at 09:28
  • Yeah I prefer using sockets for efficiency. – Reuben Debattista Jun 10 '16 at 09:29
  • 2
    I think the right answer is `mod_proxy_fcgi` - the spawning capability is important for efficiency – Colt Jun 10 '16 at 09:30
  • If I use mod_proxy_fcgi I cannot use unix sockets, unless I upgrade my apache. The problem is that this will not happen on Ubuntu 14.04 unless I use a PPA right? – Reuben Debattista Jun 10 '16 at 09:40
  • That is right. You will have to balance spawning against sockets, until 16.04. On the other hand, even with using a "port" you will get dramatic speed improvements with the 14.04 set up; test them both (`mod_proxy_fcgi` no sockets vs `mod_fastcgi` no spawning) and report back in a comment - I am sure we would all like to see the "data" – Colt Jun 10 '16 at 09:46
  • Is `mod_fastcgi` still notoriously difficult to set up and a memory hog if you are using `FastCGIExternalServer` with php-fpm? Does `mod_proxy_fcgi` have any benefits over this setup? – leeb Oct 09 '18 at 10:43
  • 4 years later .. still waiting on "report back in a comment - I am sure we would all like to see the 'data' ". – Mike Kormendy May 14 '20 at 23:42
  • mod_proxy_fcgi's benefit, esp. in Debian systems, is that you can simply install the php-fpm package and run the sudo a2enconf commands that it tells you to run, and you're done, no extra Apache configuration is required. – Josip Rodin Jul 24 '20 at 10:01