Installing Lighttpd from source on Linux

  • September 14, 2007
  • Avatar for peter

lighttpd logo Apache is the world's most popular web server and is a very good piece of software. It isn't however, the only choice of free software and open source web server solutions and it's easy to overlook lightweight alternatives to Apache.

One such alternative is lighttpd. Here's what its official site says about the project:

Security, speed, compliance, and flexibility -- all of these describe lighttpd (pron. lighty) which is rapidly redefining efficiency of a webserver; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting and many more) lighttpd is the perfect solution for every server that is suffering load problems. And best of all it's Open Source licensed under the revised BSD license.

In this tutorial, I am going to show you how to get lighttpd up and running by compiling it from source. You can of course use your distribution's package manager to install it, but here we'll go through the source-based process.

First of all, we need to head over to the Lighttpd website and download the latest source code. At the time of writing, that is 1.4.18, and the download link is

$ wget

Once that's downloaded, we'll extract the archive (substitute xjvf for xzvf and the relevant filename in the next command if you downloaded the tar.gz version):
$ tar xjvf lighttpd-1.4.18.tar.bz2

Now, we need to change into the newly extracted directory (change your version numbers if necessary):
$ cd lighttpd-1.4.18

The install is a standard source-based process. If you're familiar with that, then go ahead. For everyone else, the sequence is to run the following commands in order (obviously letting the first one finish before starting the second one and so on).
$ ./configure
$ make

Finally, you need to run make install as root. On Ubuntu, run sudo make install. Everywhere else, do this:
$ su -c "make install"

Enter your root password (or your user password in the case of Ubuntu) and confirm. That's the basic installation now done, so let's get our server up and running!

Before we do that, however, we have to get a configuration file in place and set up. Depending on your exact requirements, you'll need to have a configuration file for you. In this example, I'm going to use a very basic configuration file to get us up and running as soon as possible. You can find more help on making configuration files here on the lighttpd wiki.

server.document-root = "/var/www/"

server.port = 80

server.username = "www-data"
server.groupname = "www-data"

mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"

static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )

Save your configuration file as /etc/lighttpd/lighttpd.conf.

Back on your command line, login as root. For Ubuntu, use sudo -i or su - for everyone else. We now need to start the server daemon for the first time.

# lighttpd -D -f /etc/lighthttpd/lighttpd.conf

You should get a message along these lines:
2007-09-14 20:30:25: (log.c.75) server started

That means your server started up successfully and you should now be able to browse to http://localhost on your machine and view whatever is in /var/www (or whatever you chose as your root for the web server). Now you can get populating this directory with content!

Avatar for peter Peter Upfold

Home » Articles »