lighttpd + PHP-FPM on Debian Squeeze
I’m not a super-BOFH but I do like to host my own blog (not this on, though) and play with stuff.
In the past I used to use Apache, but I never liked the VirtualHosts configuration, specially when it gets big. Don’t get me wrong, I’m not saying its not right, its just not right for me. So I switched to lighttpd and I loved the configuration. It also has good performance.
This lighttpd server hosts a couple of WordPress blogs among other stuff and I noticed some slowness from time to time. Since its not critical to me I didn’t bother much. But then, reading some of my RSS feeds I heard about PHP-FPM. Never heard of it before.
It will run as a system daemon and take care of spawning PHP processes for handling requests when necessary, among other things. Its performance should be better than old FastCGI, so I decided to give it a try.
There is no PHP-FPM package on Debian Squeeze, but fortunately we can use the Dotdeb respository which does have one. Follow the instructions here and install PHP-FPM:
apt-get install php5-fpm
You may also want to upgrade all your PHP related packages, Dotdeb contains good and updated packages.
Now we need to configure lighttpd to use PHP-FPM. Lets create a configuration file for that in /etc/lighttpd/conf-available with the following content:
server.modules += ( « mod_fastcgi » )
fastcgi.server = ( « .php » =>
( « localhost » =>
« host » => « 127.0.0.1 »,
« port » => « 9000 »
view raw gistfile1 This Gist brought to you by GitHub.
I suggest you name the file 10-fastcgi-fpm.conf. Now lets disable old FastCGI and enable our new module:
And last, restart the server:
I didn’t benchmark it thoroughly, but my rtGUI page used to take up to 10 seconds to load and now it takes less than a second. Not bad!