Updated: 22 October 2023

Install on Ubuntu

sudo apt install lighttpd
# check version
lighttpd -v

Check if lighttpd is running

ps aux | grep lighttpd
# or
systemctl status lighttpd

Basic help

lighttpd --help

Stop the webserver (will restart when system is rebooted)

sudo systemctl stop lighttpd

Start the webserver

sudo systemctl start lighttpd

Prevent lighttbd from starting on system boot

sudo systemctl disable lighttpd

Backup the config file

sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.original.backup
sudo touch /etc/lighttpd/lighttpd.conf

A config for testing

server.document-root = "/var/www/servers/" 
server.port = 3000

# If running lighttpd earlier than lighttpd 1.4.71 add the following:
mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 

Check the conf file

lighttpd -tt -f /etc/lighttpd/lighttpd.conf

lighttpd will bind to all interfaces by default and will listen for HTTP requests on the port specified in server.port. lighttpd will then serve files from the server.document-root specified. The files in document root have to be readable by the user starting the web server.

Start the server for testing

lighttpd -D -f lighttpd.conf

Leave a comment