How to install lighttpd web server on Debian 11 Bullseye or Ubuntu 20.04

lighttpd (lighty) is a web server that requires far fewer resources than Apache, for example, and is therefore particularly suitable for very large loads or very weak systems. It was developed by Jan Kneschke and can be expanded with modules. FastCGI, for example, enables PHP code to be executed. SCGI supplements lighty with Ruby or Python.

Steps to Install Lighttpd Web server on Debian 11 or Ubuntu 20.04

Installation

lighttpd can be installed directly from the official package sources on Debian 11 Bullseye, hence we don’t need any third-party repo just like Apache. Run the given single command to install this web server.

sudo apt install lighttpd -y

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
bzip2 file libbrotli1 libgdbm-compat4 libgdbm6 libmagic-mgc libmagic1 libperl5.32 lighttpd-mod-deflate
lighttpd-mod-openssl mailcap media-types mime-support netbase perl perl-modules-5.32 spawn-fcgi xz-utils
Suggested packages:
bzip2-doc gdbm-l10n sensible-utils openssl rrdtool php-cgi php-fpm apache2-utils lighttpd-doc
lighttpd-mod-authn-gssapi lighttpd-mod-authn-pam lighttpd-mod-authn-sasl lighttpd-mod-geoip lighttpd-mod-maxminddb
lighttpd-mod-trigger-b4-dl lighttpd-mod-vhostdb-pgsql lighttpd-mod-webdav lighttpd-modules-dbi lighttpd-modules-ldap
lighttpd-modules-lua lighttpd-modules-mysql perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
libtap-harness-archive-perl
The following NEW packages will be installed:
bzip2 file libbrotli1 libgdbm-compat4 libgdbm6 libmagic-mgc libmagic1 libperl5.32 lighttpd lighttpd-mod-deflate
lighttpd-mod-openssl mailcap media-types mime-support netbase perl perl-modules-5.32 spawn-fcgi xz-utils
0 upgraded, 19 newly installed, 0 to remove and 0 not upgraded.
Need to get 8843 kB of archives.
After this operation, 57.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Install lighttpd on Debian 11 bullseye

Start & Enable Lighttpd Service

Once the installation is completed, the user can start and enable the webserver service so that it can be started automatically even after rebooting the system or server.

sudo systemctl start lighttpd
sudo systemctl enable lighttpd

To check the status:

systemctl status lighttpd

 

Lighttpd Configuration on Debian 11 or Ubuntu

The Lighttpd is configured via the file /etc/lighttpd/lighttpd.conf . This can be edited with any text editor with root rights. Numerous configuration options are described in detail in the configuration file itself.

Example:

sudo nano /etc/lighttpd/lighttpd.conf

 

Enable CGI

CGI is an interface between the web server and the operating system, for example, to execute Perl scripts via the webserver. Dynamic content can be generated in this way. So, this module can be activated via this command:

sudo lighty-enable-mod cgi

 

Access default Lighttpd web page

Open your browser and point to the server ip-address where you have installed the Lighttpd web server. You will get the default page of this web server.

Default web server page lighttpd

 

HTTP authentication

In order to provide directories with password protection, the auth module is required and can be activated via

sudo lighty-enable-mod auth
sudo service lighttpd force-reload

The use of .htaccess files known from Apache is unfortunately not possible with lighty. Instead, the settings must be made in the configuration file /etc/lighttpd/conf-enabled/05-auth.conf, and the webserver restarting is required.

Authentication is possible with basic and digest, whereby the backends plainhtpasswdhtdigest and ldap can be used.

For example, in order to provide the directories /server-status and /server-statistics with basic authentication via .htpasswd, the following entry is required in 05-auth.conf :

auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/lighttpd/htpasswd"
auth.require                 = ( "/server-status" =>
                                ( 
                                  "method"  => "basic",
                                  "realm"   => "server status",
                                  "require" => "valid-user"
                                ),
                                "/server-info" =>
                                ( 
                                  "method"  => "digest",
                                  "realm"   => "server info",
                                  "require" => "valid-user"
                                )
                              )

For more information see the official documentation. 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.