Installing and configuring lighttpd webserver – HOWTO

lighttpd is a web server for UNIX/Linux and Windows operating systems. It is an alternative to Apache web server. It is also called Lighty.

It is designed to be secure, fast, standards-compliant, and flexible while being optimized for speed-critical environments. Its low memory footprint (compared to other web servers), light CPU load and its speed goals make lighttpd suitable for servers that are suffering load problems. Visit official site for more information.

This document shows you how to install lighttpd and covers basic configuration.

Installing lighttpd

If you are using RPM based distro (RedHat, Fedora and friends) download RPM and other formats here. Binary RPM is here

Download Fedora Core RPM Binary:

$ cd /tmp
$ wget
$ su -
# rpm -ivh lighttpd-1.4.13-1.i386.rpm

Now skip to configuration section.

Debian Linux user use apt-get command to install lighttpd:

# apt-get install lighttpd

Now skip to configuration section.

Source code installation

Above RPM binary does not carries mod_rewrite and other stuff, so I had decided to rebuild lighttpd from source code (note source code installation is recommended for advanced users only):
$ cd /tmp

Get latest source code:
$ wget

Untar tar ball:
$ tar -zxvf lighttpd-1.4.13.tar.gz
$ cd lighttpd-1.4.13

Configure lighttpd with ./configure

$ ./configure --host=i686-redhat-linux-gnu \
--build=i686-redhat-linux-gnu \
--target=i386-redhat-linux \
--program-prefix= --prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/usr/com \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-openssl \
--with-pcre \
--with-zlib \
--with-bzip2 \
--disable-ipv6 \
--with-PACKAGE=mod_redirect \
--with-rewrite \
--with-redirect \

Above configure option includes support for SSL, mod_rewrite, ssi, mod_redirect etc. Run following command to get help on all other available options:
$ ./configure --help | less

Install lighttpd:
$ make
# make install

Create a configuration directory:
# mkdir /etc/lighttpd/

Create lighttpd user and group:
# groupadd lighttpd
# useradd -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd

# adduser -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd

Create a log directory:
# mkdir /var/log/lighttpd
# chown lighttpd:lighttpd /var/log/lighttpd

Download sample config and startup files:
# cd /etc/lighttpd
# wget
# mv lighttpd.conf.txt lighttpd.conf
# chown lighttpd:root /etc/lighttpd/lighttpd.conf
# cd /etc/init.d/
# wget
# mv lighttpd.txt lighttpd
# chmod +x lighttpd

Configuring lighttpd

Following are important files for lighttpd server:

  • The default lighttpd configuration file: /etc/lighttpd/lighttpd.conf (download sample lighttpd.conf file)
  • Service startup script: /etc/init.d/lighttpd (download sample lighttpd file)

These files are installed by default for all binary installations methods. Now lighttpd installed and it is time to configure lighttpd.

Remove apache

If you are not going to use Apache v1.3/2.x at all, then it is better to remove it (make sure you have a backup of Apache data and config file):
# rpm -e httpd
# yum remove httpd
# apt-get remove apache2

Understanding core lighttpd Directives

Following are core lighttpd Directives:

  • server.document-root = “/var/www/html”: Specifies default document-root for your server.
  • server.port = 80: Specifies default http port for your server.
  • server.username = “lighttpd”
  • server.groupname = “lighttpd”: Specifies default username and groups to start/stop lighttpd server. This is a security feature (as it drops root privileges).
  • server.bind = “server-ip-address”: Specify server ip-address. You can also specify hostname such as
  • server.tag =”lighttpd”: Use to setup lighttpd name and version number (default). This is security feature. You can setup it as follows:
    server.tag ="myWebServer v1.0"
    Please note that this name is reported by the Server response header (you can see it using netcraft)
  • server.errorlog = “/var/log/lighttpd/error.log”: Specify the error-log file.
  • accesslog.filename = “/var/log/lighttpd”: Specify the accesslog file name (use to generate stats using stats software).
  • index-file.names = ( “index.php”, “index.html” ): A list of files to search for if a directory is requested.

server.modules = (
: Above modules are loaded by lighty:

  • mod_access: The access module is used to deny access to files with given trailing path names.
  • mod_accesslog: Use to write CLF log, flexible like apache
  • mod_fastcgi : FastCGI for perl/PHP etc
  • mod_rewrite : Good for writing SEO urls
  • mod_auth: Authntication (password protected directory)

mimetype.assign = (
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”
: Use to setup mimetype mapping.

Open file /etc/lighttpd/lighttpd.conf and setup all of the above directives:
# vi /etc/lighttpd/lighttpd.conf

Save the file and start the lighttpd:
# /etc/init.d/lighttpd start

Verify that lighttpd is running:
$ netstat -ntulp


Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0        *                   LISTEN      29855/sshd
tcp        0      0 *                   LISTEN      5866/lighttpd

Fire your web browser and test new setup by typing URL: or http://server-ip/

Next time I will cover following topics:

Lighttpd How to

Lighttpd security

Lighttpd software configuration how-tos

Lighttpd Server Monitoring

Lighttpd Troubleshooting

Download: Lighttpd Sample config and RPM files

This is regularly updated series. Last Updated on 10-Dec-2006 by nixCraft.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 24 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • Srinivasan R Jul 8, 2006 @ 11:24

    I would really like to know how to setup cgi-bin and to execute cgi applications in lighttpd.

  • 🐧 nixCraft Jul 9, 2006 @ 8:23

    Add mod_cgi to server.modules i.e following command:
    server.modules += ( “mod_cgi” )

    Add alias url:
    alias.url += ( “/cgi-bin/” => “/var/www/cgi-bin/” )

    Add following url:
    $HTTP[“url”] =~ “/cgi-bin/” {
    cgi.assign = ( “.pl” => “/usr/bin/perl” )

    I will cover detailed article later on

    • prasad Oct 21, 2016 @ 6:21

      hi ,

      I am using lighttpd with C CGI to do configuration and retrieve values in the system.
      For each cgi query i see a process is spawned till it returns success/failure to lighttpd. Is there a option in lighttpd.conf to limit the time lighttpd should wait fro this cgi process to return ?

      Thank you .

  • Gerard Oct 14, 2006 @ 17:51

    About ./configure:
    I really doubt you would need all those options, configure can figure them out itself, for example –host=i686-redhat-linux-gnu or all those directories.

  • 🐧 nixCraft Oct 18, 2006 @ 19:58

    You can skip following

    But rest is required to make sure /etc/init.d/lighttpd and other scripts find them.

  • LavaLamp Dec 9, 2006 @ 20:48


    This is an excellent collection. I would like to see more tutorials and configuration howtos – Rub on Rails and Python lighttpd configuration.

    Thanks for all wonderful tutorials.

  • TECK Apr 19, 2007 @ 5:31

    Hi nixcraft,

    I was wondering if you could look the RPM I built on CentOS5 and tell mw what I did wrong:

    For some reason, the memcache option is disabled.
    If I use the 1.4.13 archive everything is ok, so I believe is lighty bug.

    Thanks for your help.

  • Premkumar May 9, 2007 @ 22:44


    This tutorial is very helpful for my team. Thanks a lot…..

  • kunal Jul 23, 2007 @ 10:52

    This tutorial is very helpful for me.

    Thanks a lot !!!!!!!!!

  • Madhavi Sep 12, 2007 @ 11:42


    Can we write cgi-bin programs in C and run on lighttpd??

  • 🐧 nixCraft Sep 12, 2007 @ 16:22

    Yes you can write program in c/c++ and run as cgi-bin

  • harish Sep 26, 2007 @ 4:48

    this is really nice tutorial and seriously help me a lot but anyone can tell how can i remove flowplayer logo from my fullscreen mode ????

  • Hoteles Mar del Plata Jul 5, 2008 @ 18:46

    Good Word Server Web Daemon!!!!

    Exceln Howto!!!

  • Aaron Fay Oct 22, 2008 @ 20:36

    Thank you so much, worked like a charm!

  • dendy b sulistyo Jan 9, 2009 @ 16:21

    when i use apache+php+mysql+wordpress 2.5, the insert image is working.
    after following your tutorial, using lighttpd+php+mysql+wordpress 2.5 the insert image is not working. any experience about that ?
    is this permition problem ? or ownership ?

  • 🐧 nixCraft Jan 9, 2009 @ 17:50

    @ dendy,

    Find out if session.save_path (php.ini) exists and owned by lighttpd.

  • V.Balaviswanathan May 12, 2009 @ 14:11

    Thanks a lot for your tutorials

  • txaume Jun 18, 2009 @ 13:59

    Good tutorial, tanks!
    But now, i guess if there’s any way to fix user and only ask for password when youauthenticate any user that tries to load a web hosted in my lighttpd server. I mean, when the usual login popup appears, it has to be something like that:
    any ideas?
    Thanks in advance!

  • Ela Oct 1, 2009 @ 15:52

    Am using httpd server and am having the error log file problem, file will be created and its size is increasing without end. i already posted three posts. sorry to posted this much times because i need the solution. Please can you find out whats happening exactly.

  • Oragon Mar 8, 2010 @ 21:45

    Hello all,
    I configured Lighty with FastCGI and PHP successfully and am able to serve dynamic content as well. However, I will eventually run the server on a memory constrained device. Hence I would prefer using C instead of PHP. Assuming I am able to build a fastCGI-C application, how do I configure Lighty to work with this setup ? I have done all the preliminary online research and have RTFM, but things still are not clear.
    If anyone can shed some light, it would be awesome of them !!!

  • suresh Aug 10, 2010 @ 14:30

    i am using lighttpd1.4.24 server in ubuntu.i have a python script as in my server.document-root so that when i start my lightty server the script gets run..inside the script i need to redirect the server to a particular url(ex=[Link to])..can anyone give me the entire python script..i have tried with some but nothing works for me but server running successfully without redirection..

  • Faisal Mar 29, 2012 @ 8:46

    Is this method applicable for Lighttpd version 14.30 if I wanna install it in CentOS 6.2 ? I tried to install it from rpm but I need the source files as I have to make a plugin using those source files. So, please let me know whether I need to change somethings here.

  • Kyeray Sep 2, 2013 @ 11:53

    I installed lighttpd from source code in ubuntu 12.04. But there is no rc.d file in /etc. There are rc0.d, rc1.d etc and also rclocal.d. When I type service lighttpd restart I get the following error.
    /etc/init.d/lighttpd: 18: .: Can’t open /etc/rc.d/init.d/functions. When I searched /etc/init.d/lighttpd it has the following line
    # Source function library
    . /etc/rc.d/init.d/functions
    I cannot start the service. I am relatively new in linux. Please help

  • Jose Mar 24, 2014 @ 15:44


    Is Lighttpd 1.4.13 compatible with windows server 2012?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum