Apache + SuExec + php-fpm – how to set them up

apache-2.2mod-fcgidphp-fpmsuexecsuphp

I wonder if there is a good guide on how to setup Apache + SuExec + php-fpm? I have a server which I am going to use several separate website. So, I need php to be run as site-owner user. As I can see, php-fpm is a little different from php-fcgi. Is there a need in mod_fcgid from Apache in this case? How to set this all up?

For now my site is running Apache + mod_suphp + php-cgi, so… it's good, but a little slow. I want to preserve security and gain an ability to use APC.

Best Answer

PHP-FPM is a patch for PHP to provide some advanced process management features which are useful when used in its FastCGI variant. On a side note, PHP 5.4 will probably include PHP-FPM out of the box (according to Antony Dovgal).

Since mod_fcgid doesn't support externally spawned FastCGI servers, you need to use mod_fastcgi or mod_proxy_fcgi.

Google found this two-part tutorial (Part 1, Part 2) which describes the configuration of Apache httpd, suEXEC, mod_fastcgi, PHP-FPM and APC. I haven't tried the tutorial but it should give you an idea of how to configure it.