The new way running PHP on apache not as a module but over fcgid can increase the performance on a multicore CPU system and it is possible to run the PHP process not as the apache user (often www-data), but for example as the ftp user. So when apache creates a file the owner is not www-data, but the ftp user.
I’ve seen many setups allowing ExecCGI for the vhost. That is a bad practice. It is much better allow it only for the needed files.
<VirtualHost *:80> ServerName example.local DocumentRoot "/Users/mario/www" CustomLog "C:\nul" common <IfModule fcgid_module> FcgidPassHeader Authorization <Files ~ "\.php$"> Options ExecCGI AddHandler fcgid-script .php FcgidWrapper "C:/users/mario/php5/php-cgi.exe" .php </Files> </IfModule> <Directory "/Users/mario/www> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
With the module it was possible to highlight PHP file with x-httpd-php-source. That option is not available with fcgid. So I had to think how to enable with but not going back to the module which often crashed my apache.
What works is to use the php parameters on the command line.
<Files ~ "\.phps$"> Options ExecCGI AddHandler fcgid-script .php FcgidWrapper "C:/users/mario/php5/php-cgi.exe -s" .php </Files>
A full example on Windows.
<IfModule fcgid_module> FcgidConnectTimeout 10 FcgidMaxProcesses 300 FcgidMaxProcessesPerClass 300 FcgidOutputBufferSize 64 ProcessLifeTime 0 FcgidMaxRequestsPerProcess 0 FcgidMinProcessesPerClass 0 FcgidFixPathinfo 0 FcgidProcessLifeTime 0 FcgidZombieScanInterval 20 FcgidMaxRequestLen 536870912 FcgidIOTimeout 120 FcgidTimeScore 3 </IfModule> <VirtualHost *:80> ServerName example.local DocumentRoot "/Users/mario/www" CustomLog "C:\nul" common <IfModule fcgid_module> FcgidInitialEnv PHPRC "C:\\Users\mario\\php5" FcgidInitialEnv PATH "C:\\Users\mario\\php5;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;" FcgidInitialEnv SystemRoot "C:\\Windows" FcgidInitialEnv SystemDrive "C:" FcgidInitialEnv TEMP "C:\\WINDOWS\\TEMP" FcgidInitialEnv TMP "C:\\WINDOWS\\TEMP" FcgidInitialEnv windir "C:\\WINDOWS" FcgidPassHeader Authorization <Files ~ "\.php$"> Options ExecCGI AddHandler fcgid-script .php FcgidWrapper "C:/users/mario/php5/php-cgi.exe" .php </Files> <Files ~ "\.phps$"> Options ExecCGI AddHandler fcgid-script .php FcgidWrapper "C:/users/mario/php5/php-cgi.exe -s" .php </Files> </IfModule> <Directory "/Users/mario/www> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
On Linux is is just a little different
FCGIWrapper /usr/bin/php5-cgi .php
and only
FcgidPassHeader Authorization