Lighttpd, fastcgi, php and eAccelerator

lighttpd is a lightweight httpd server I came across on #wordpress (thanks michel_v!)
It took a while but I got it working on a server and it’s rather nice. You can run php scripts through it using the fastcgi interface. Here’s how I installed it on a Debian machine. Lines starting with “#” are commands that should be entered as the root user. (lots ripped from this tutorial)

# wget http://www.lighttpd.net/download/lighttpd-1.3.13.tar.gz
# tar zxvf lighttpd-1.3.13.tar.gz
# cd lighttpd-1.3.13
# dpkg-buildpackage

dpkg-buildpackage can be found in the package “cvs-buildpackage”. You’ll have to install a number of dependencies before this works. Just apt-get install packagename them as they come up.

# cd ..
# dpkg -i lighttpd_1.3.13-1_i386.deb

This will install lighttpd and start it.
Now you need to install and configure php:

# apt-get install php4-cgi
# vi /etc/lighttpd/lighttpd.conf

Look for the fastcgi.server section for php4 and change it so it looks like this:

fastcgi.server = ( ".php" =>
  ( "localhost" =>
    (
      "socket" => "/tmp/php-fastcgi.socket",
      "bin-path" => "/usr/bin/php4-cgi"
    )
  )
)

Download eaccelerator from their site and follow the instructions in the README. If you haven’t got phpize then install php4-dev.
Open up /etc/php4/cgi/php.ini and add the following at the top of the file:

  extension="eaccelerator.so"
  eaccelerator.shm_size="32"
  eaccelerator.cache_dir="/tmp/eaccelerator"
  eaccelerator.enable="1"
  eaccelerator.optimizer="1"
  eaccelerator.check_mtime="1"
  eaccelerator.debug="0"
  eaccelerator.filter=""
  eaccelerator.shm_max="0"
  eaccelerator.shm_ttl="1800"
  eaccelerator.shm_prune_period="1800"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"
  eaccelerator.content="shm_and_disk"

You’ll have to create the tmp directory yourself. Read the README file and config docs for instructions on using the web frontend to the accelerator.

I think that’s it, have I forgotten anything?


6 Comments

Pingback: Programmin' Prim8 (1 comments.)

Eugen Leitl (1 comments.) on May 25, 2005 at 2:07 pm.

Excellent instructions. I’ve just followed them through without any hitch. I would include some of the external information you’re pointing to verbatim (e.g. chmod 0777 /tmp/eaccelerator ) as these have a tendency to turn into 404s very soon.

Reply

Pingback: http://leitl.org » Blog Archive » Houston, we have ignition… (1 comments.)

smurfix on August 12, 2005 at 9:20 am.

Try not to build packages as root.

# apt-get install fakeroot
$ dpkg-buildpackage -rfakeroot

Reply

Eugen Leitl (1 comments.) on November 29, 2005 at 3:32 pm.

This still works for PHP5 on Debian. Notice that
fastcgi.server and /etc/php4/cgi/php.ini need to have
backslashes removed (it’s obvious, but I got bitten
by it the very first time).

Reply

Imu on December 12, 2007 at 1:51 pm.

How would I configure wp-super-cache for lighttpd ?

Reply

Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>