Read about how to quickly install Lighttpd, equiped with php5-cgi and xcache: a great alternative to LA(M)P.
For the myp2p website, we are running on Lighttpd with fastcgi php5. To improve performance, we installed xcache, a PHP opcode cacher. Xcache seems to improve the performance with about 20%, as far as that can be quantified in a percentage.
Instead of using the oftenly chosen Apache, we’re going with the more controversial and less known lighttpd (pronunciation lighty). Compared to Apache, lighttpd gives us a performance improvement as well. Especially on high load peaks, lighttpd can handle much more requests on our hardware.
For our so called backend webservers (the servers that produce the actual content on the website) I have developed a small installation guide of lighttpd tuned with php5 and xcache. I will also attach a lighttpd and xcache config file, as well as a lighttpd startup script (nicked from the debian package).
First, let’s install lighttpd. This can either be done from the sourcecode or debian package. The stable lighttpd debian package is based on lighttpd version 1.4.13. The lighttpd project is at the time I type this working with version 1.4.18, so a chose for the sourcecode compilation.
wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.gz tar xzf lighttpd-1.4.18.tar.gz cd lighttpd-1.4.18 apt-get install zlib1g zlib1g-dev libpcre3 libpcre3-dev ./configure --without-bzip2 make make install
Now install the startup file in the /etc/init.d/ directory (in attachement). Also copy the lighttpd.conf file to /etc/lighttpd/.
I installed php5 using debian packages, because this saves its loads of compiling time. The available php5 packages seem to be reasonably up to date
apt-get install php5-cgi apt-get install php5-dev
I installed the php5-dev package for the phpize tool, which we will use later on. You might also be interested in libraries like:
apt-get install php5-gd apt-get install php5-mysql
As well as lighttpd, I installed xcache from the sourcecode:
wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz tar xzf xcache-1.2.2.tar.gz cd xcache-1.2.2 phpize ./configure --enable-xcache make make install mkdir /usr/share/xcache cp -r ./admin /usr/share/xcache/
Now put the xcache.ini file in the php-cgi includes directory: /etc/php/cgi/conf.d/. A final thing to do is to start lighttpd using the startup script. What lighttpd basically does is start a cople of php5-cgi processes (number specified in lighttpd.conf). In contrast with a normal cgi process, lighttpd will keep the cgi process alive after running a script. This means that for example persistent mysql connections will work. It also removes some other drawbacks a cgi process usually has.