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 supplemented with modules. FastCGI, for example, allows you to execute PHP code. SCGI slightly complements Ruby or Python.
Steps to Install Lighttpd Web Server on Debian 11 or Ubuntu 20.04
lighttpd can be installed directly from 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
To go out:
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 enable the Lighttpd service
After the installation is complete, the user can start and enable the web server service so that it can be started automatically even after system or server restart.
sudo systemctl start lighttpd sudo systemctl enable lighttpd
To check the status:
systemctl status lighttpd
Lighttpd setup 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. 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 execute Perl scripts through the web server. Dynamic content can be generated this way. Thus, this module can be activated via this command:
sudo lighty-enable-mod cgi
Access 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 protect the directories by password, 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 is unfortunately not possible with lighty. Instead, parameters must be set in the configuration file
/etc/lighttpd/conf-enabled/05-auth.conf, and web server restart is required.
Authentication is possible with basic and digestwhere 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.