I just setup my server with Apache, FastCGI, and PHP-FPM. My question is regarding the /cgi-bin/ folder: is it really necessary to have a /cgi-bin/php-fpm wrapper for every single virtualhost that runs apache using a different user/group? Furthermore, if a user deletes the cgi-bin folder... the fpm/fastcgi benefits are lost. Ideally, I'd like to setup PHP-FPM without the need for anything outside of the .conf file.

As far as I can tell, the php-cgi binary (which is all that the php-fpm wrapper executes) is executable by all users on the system... so why the hassle of wrapping the same executable that's going to be run by the user anyway? More specifically, how can I change this configuration to use the php-cgi binary directly, instead of going through the wrapper?

The relevant files/results related to my question are:

/etc/apache2/modules.d/20_mod_fpm.conf
---------------------------------------------------------------------------------
...

FastCgiExternalServer /var/www/localhost/cgi-bin/php-fpm -host 127.0.0.1:9000

AddHandler php-fpm .php
Action php-fpm /cgi-bin/php-fpm

DirectoryIndex index.php

...
/var/www/localhost/cgi-bin/php-fpm
---------------------------------------------------------------------------------
#!/usr/bin/php-cgi
phpinfo()
---------------------------------------------------------------------------------
...
Server API: FPM/FastCGI
...

Lovely. Running benchmarks reports that the setup is, indeed, functioning very well: with ~135 requests per second, rather than 13 requests per second using the default Apache/PHP interpreter setup. So all that's left is making the multi-user aspect seamless.

link|improve this question

50% accept rate
feedback

1 Answer

Using a wrapper allows you to optionally do additional configuration such as setting environment variables, selecting a php.ini file, etc.

link|improve this answer
Okay, so the wrapper isn't necessary after all. I'll modify my question to include the question of how to remove the wrapper from the configuration, because if I do so right now and just point FastCGIExternalServer straight to the php-cgi binary, it doesn't do the same thing as when php-cgi is executed by another application. (Something to do with the Option ExecCGI, I think?) – Caleb Gray Jan 5 at 0:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.