Sunday 13 April 2014

Lighttpd - lightweight low footprint web server




Having used Apache server for a long time I was looking for a web server with a much lower memory footprint. The solution I found was Lighttpd which is pronounced 'lighty'. Its used by many web sites including YouTube and Wikipedia as it allows them to scale a lot better with the same hardware. Its easy to use, powerful and quick to setup.

Pre Installation Check

  • Default listen port is 80
  • Check nothing is already bound to port 80
$ netstat -an | grep -i 80  
  • If the port was bound you would see 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN 

Installation
  • On Linux Mint, Ubuntu or Raspberry Pi 
$ sudo apt-get -y install lighttpd 
  •  Lighttpd will automatically start. Check the port is now bound
$ netstat -an | grep -i 80 
  • Check status
$ /etc/init.d/lighttpd status
 * lighttpd is running




Manual Bug Fix
  • In the latest builds the default lighttpd.conf contains a bug
  • Open in a text editor and find the line starting 'index-file.names'
$ sudo vi /etc/lighttpd/lighttpd.conf


  • As hightlighted above there is an extra quoue in " index.lighttpd.html"
  • Remove quote and save as shown below


  • Restart service
$ sudo /etc/init.d/lighttpd restart

Change Default Port
  • Its a good idea to change the default listening port from 80 to another non bound port
  • I am going to change it to port 8888
  • First check nothing is listening on that port
 $ netstat -an | grep -i 8888
  • Open config file in text editor
$ sudo vi /etc/lighttpd/lighttpd.conf
  • Add
 server.port = 8888
  •  Save file and restart
$ sudo /etc/init.d/lighttpd restart
File and Directory Details
  • HTML files location : /var/www
  • Default directory index : index.html
  • CGI Scripts : /usr/lib/cgi-bin
  • Logs : /var/log/lighttpd
Further Configuration
  • Lighttpd has many support modules that enhance functionality
  • RRDTool can be used for statistics



No comments:

Post a Comment