In this article, we will have explained the necessary steps to install and setup Lighttpd on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Lighttpd is a free, open-source and high-performance web server developed by Jan Kneschke. It has a low memory footprint when compared to other web servers and is specially designed for speed-critical environments. It is secure, fast, and can handle up to 10,000 connections in parallel on a single server. Lighttpd comes with a rich set of features, such as FastCGI, SCGI, Auth, URL-Rewriting, Output-Compression, event mechanism, and more.
Install Lighttpd on Debian 10
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgrade
Step 2. Install Lighttpd on Debian 10.
Install Lighttpd from the Debian repository using the apt package manager:
sudo apt install lighttpd
After successfully install Lighttpd, start and enable the service to automatically start at boot time:
sudo systemctl start lighttpd sudo systemctl enable lighttpd sudo systemctl status lighttpd
Once it has been installed, we will be able to check the operation of it, opening a web browser and going to http://YOUR_SERVER_IP or http://localhost if we are in a local machine. Remember that this works through port 80 and it has to be available.
Step 3. Enabling the PHP support to Lighttpd.
The first step is to install PHP and some of its modules, to do this, use the following command:
sudo apt install php7.3 php7.3-fpm php7.3-mysql php7.3-cli php7.3-curl php7.3-xml
By default, PHP-FPM listens on the UNIX socket
/var/run/php73-fpm.sock. So, we will need to modify the file
/etc/php/7.3/fpm/pool.d/www.conf and set PHP-FPM to listens on TCP socket:
sudo nano /etc/php/7.3/fpm/pool.d/www.conf
listen = 127.0.0.1:9000
Save and close the file. Next, open the file 15-fastcg-php.conf to enable FastCGI support in Lighttpd:
"bin-path" => "/usr/bin/php-cgi", "socket" => "/var/run/lighttpd/php.socket",
"host" => "127.0.0.1", "port" => "9000",
Save and close the file. Then, enable FastCGI and FastCGI-PHP modules with the following command:
lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php
Finally, restart Lighttpd and PHP-FPM service to apply all the configuration changes:
sudo systemctl restart lighttpd sudo systemctl restart php7.3-fpm
Step 4. Configure Firewall
Issue the following commands to allow HTTP (80) and HTPPS (443) request through the firewall:
ufw allow 80/tcp ufw allow 443/tcp ufw reload
Congratulation, you have learned how to install and configure Lighttpd on Debian Buster. If you have any question, please leave a comment below.