Friday, February 28, 2014

How to install Lighttpd on Mountain Lion OS X 10.8

Below are few steps you need to follow to install Lighttpd on 1.4.34 on Mac OS X 10.8 (Mountain Lion)

1) Download Lighttpd from http://www.lighttpd.net/

2) If you don't have command line tools installed (by default they are not) then download it from


These tools include C compiler which is required to make lighttpd.

3) Now download and install pcre library  pcre-8.34.tar.bz2
http://sourceforge.net/projects/pcre/files/latest/download?source=files
Its one of the dependency required by lighttpd

tar xzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && sudo make install
cd ../

4) Now install lighttpd

tar xzf lighttpd-*.tar.gz
cd lighttpd-*
./configure
make && sudo make install

While installation, terminal might show below messages
make[5]: Nothing to be done for `all'.
make[5]: Nothing to be done for `all-am'.
make[4]: Nothing to be done for `all-am'.
make[3]: Nothing to be done for `all-am'.

These are harmless messages and don't get puzzled by them.

5) Now add /usr/local/sbin to PATH environment variable

6) Then create lighttpd.conf file with below content

server.document-root = "/var/www/servers/www.example.org/pages/" 

server.port = 3000

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

7) First, check that your configuration is ok:

$ lighttpd -t -f lighttpd.conf
8) Now start the server for testing:

$ lighttpd -D -f lighttpd.conf
and point your browser to http://127.0.0.1:3000/

Browser might show "Not Found" because server.document-root might not be correct in your case.

9) To stop the server, return to the command prompt and press ctrl-c.