lighttpd (lighty) is a web server that requires much less 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 extended with modules. FastCGI, for example, allows you to run PHP code. SCGI complements slightly with Ruby or Python.
Steps to install Lighttpd web server on Debian 11 or Ubuntu 20.04
lighttpd can be installed directly from the official package sources on Debian 11 Bullseye, so we don’t need a third-party repository like Apache. Run the given single command to install this web server.
sudo apt install lighttpd -y
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
Start and activate the Lighttpd service
After the installation is complete, the user can start and activate the web server service so that it can be started automatically even after restarting 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 changed with any text editor with root rights. Many configuration options are described in detail in the configuration file itself.
sudo nano /etc/lighttpd/lighttpd.conf
CGI is an interface between the web server and the operating system, for example, to run Perl scripts through the web server. Dynamic content can be generated in this way. Thus, this module can be activated via this command:
sudo lighty-enable-mod cgi
Go to the default Lighttpd web page
Open your browser and point to the IP address of the server where you installed the Lighttpd web server. You will get the default page for this web server.
In order to provide directories with password protection, the authentication module is required and can be activated via
sudo lighty-enable-mod auth sudo service lighttpd force-reload
The use of .htaccess files known to Apache are unfortunately not possible with lighty. Instead, settings must be made in the configuration file
/etc/lighttpd/conf-enabled/05-auth.conf, and restarting the web server is required.
Authentication is possible with basic and digest, where the backends plain, htpasswd, htdigest and ldap can be used.
For example, in order to provide the / server-status and / server-statistics directories 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.