Apache HTTP Server 2.4.9 was recently released and will be soon available in Fedora 20 updates.

This version integrates an upstream fix (not yet applied in the official release) to redirect requests to a FastCGI proxy using the SetHandler directive.

As the ProxyPassMatch directive is evaluated as the very beginning of each request:

  • AddType (for MultiView) or DirectoryIndex directives are not usable
  • right management per directory is not available
  • each Alias directive needs another proxy rule

The SetHandler directive, evaluated later, is much more flexible / usable. It is used (recommended) for mod_php

<FilesMatch \.phps$>
      SetHandler application/x-httpd-php-source
</FilesMatch>

Thanks to this improvement, using php-fpm is, now, as simple as mod_php.

To redirect the PHP scripts to the FPM server:

<FilesMatch \.php$>
     SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

Warning: if you remove or disable mod_php, you also need to remove all the php_value and php-flag directives, for example, making them conditional:

<IfModule  mod_php5.c>
       php_value session.save_handler "files"
        php_value session.save_path    "/var/lib/php/session"
        php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"
</IfModule>

By the way, we can also take advantage of  dropping mod_php to switch from the prefork MPM to a threaded one:

#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule mpm_event_module modules/mod_mpm_event.so

Then, most of the web applications work as usually, except those using http authentication, which is not (yet) supported by FPM.

To be followed: switch to Unix Domain Sockets announced with 2.4.9 but which works only partially (fix are under review).