Remove Apache, Install Lighttpd

I was asked in my previous post as to why I installed the popular Apache web server instead of lighttpd, a fast and highly optimized web server with a small footprint. If you need enough convincing, Youtube, Wikipedia and Meebo all use the lighttpd web server. Well, if you asked for it, you’ll going to get it. This article is a how-to in removing Apache and replacing it with the lighttpd web server.

Remove Apache

sudo apt-get remove apache2

Remove Apache from startup

sudo update-rc.d -f apache2 remove

Install lighttpd

sudo apt-get install lighttpd

Install PHP-5 and modules

sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Edit php.ini and set cgi.fix_pathinfo to 1

sudo vi /etc/php5/cgi/php.ini

Set cgi.fix_pathinfo = 1

Add lighttpd user

sudo useradd -d /home/lighttpd -m -s /bin/bash lighttpd

Add lighttpd group

sudo groupadd lighttpd

Set mod_fastcgi and mod_rewrite

sudo vi /etc/lighttpd/lighttpd.conf

Uncomment the following lines:

Add FastCGI</strong>
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"bin-environment" => (

Set file permissions to log files

sudo chown -R lighttpd:lighttpd /var/log/lighttpd/error.log
sudo chown -R lighttpd:lighttpd /var/log/lighttpd/access.log

Set WordPress Permalinks

sudo vi /etc/lighttpd/lighttpd.conf 
server.error-handler-404 = "/index.php"

Restart lighttpd web server

sudo /etc/init.d/lighttpd force-reload
sudo /etc/init.d/lightttpd restart

2 thoughts on “Remove Apache, Install Lighttpd

  1. Very nice article ulysses 🙂 I’m now trying it on my machine on both systems – Windows XP and Ubuntu 9.04 :]

Comments are closed.