mod_spdy

Using mod_spdy with PHP

Much like the Apache Worker MPM, mod_spdy is a multithreaded module, and processes multiple SPDY requests from the same connection simultaneously. This poses a problem for other Apache modules that may not be thread-safe, such as mod_php. Fortunately, it is fairly easy to adjust your Apache configuration to make your existing PHP code safe to use with mod_spdy (and with the Worker MPM as well).

Checking your current PHP setup

If you are running a site with PHP, there are two common setups. The first is to use mod_php, with the Apache Prefork MPM. The second is to use mod_fcgid. As when using the Worker MPM, when using mod_spdy it is important to use this second setup.

To quickly check which setup you are currently using, run the command apache2ctl -M (or httpd -M on some systems), which will list all the Apache modules you have installed. If you see something like php5_module in the list, you are using mod_php, and will need to adjust your setup for use with mod_spdy. If you don't see that but instead you see fcgid_module in the list, then it is probably already safe for you to install and use mod_spdy.

Configuring PHP for use with mod_spdy

Configuring PHP to work with mod_spdy is very similar to configuring PHP to work with the Worker MPM. Instead of using mod_php, you can use mod_fcgid which manages separate processes dedicated to running PHP.

To switch to PHP via mod_fcgid, follow the Apache mod_fcgid example (scroll down a bit on that page, to the PHP example).

It's important to also uninstall or disable mod_php as part of making the switch to mod_fcgid, since it's now mod_fcgid that's responsible for running PHP. On Ubuntu:

sudo a2dismod php
sudo apt-get install php5 php5-cgi libapache2-mod-fcgid

Then add the following to your httpd.conf, which tells Apache to route requests for PHP scripts to mod_fcgid (this is a simplified version of the Apache mod_fcgid example linked to above):

<Location />
AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /usr/bin/php-cgi .php
</Location>

Restart Apache and you should now be serving PHP via mod_fcgid, in a way that's compatible with mod_spdy or with the Worker MPM.

There are some additional mod_fcgid configuration details that you may want to read about in the Apache mod_fcgid example documentation.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.