DebianDebian BasedTutorials

How To Install Lighttpd with PHP on Debian 11

Install Lighttpd with PHP on Debian 11

In this tutorial, we will show you how to install Lighttpd with PHP on Debian 11. For those of you who didn’t know, Lighttpd (pronounced ”lighty”) is open-source and is a secure, fast, standards-compliant web server designed for speed-critical environments. Lighttpd needs low memory which makes that popular among other web servers. Its small size is 1MB and has low CPU and RAM usage.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Lighttpd with PHP on a Debian 11 (Bullseye).


  • A server running one of the following operating systems: Debian 10 or Debian 11.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Lighttpd with PHP on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing Lighttpd on Debian 11.

By default, Lighttpd is available on Debian 11 base repository. So, now run the following command below to install the Lighttpd packages on your Debian system:

sudo apt install lighttpd

After successfully installation, enable Lighttpd (to start automatically upon system boot), start, and verify the status using the commands below:

sudo systemctl enable lighttpd
sudo systemctl start lighttpd
sudo systemctl status lighttpd

Step 3. Accessing Lighttpd Web Server.

Once successfully installed, open a web browser on your system and type the server’s IP in the address bar. You will get the default Lighttpd server page:

Install Lighttpd with PHP on Debian 11

Step 4. Installing PHP and PHP-FPM.

Lighttpd web server won’t be usable without PHP FastCGI support. Now we run the following command to install the PHP and PHP-FPM packages to your system:

sudo apt install php php-cgi php-fpm php-mysql

Next, edit the php.ini file and set cgi.fix_pathinfo to 1:

nano /etc/php/7.4/fpm/php.ini

Add the following file:


Save and close the file, then replace the default PHP-CGI configuration and PHP-FPM socket:

nano /etc/php/7.4/fpm/pool.d/www.conf

Find the following line:

listen = /run/php/php7.4-fpm.sock

Now replace with the following line:

listen =

Finally, restart the PHP-FPM service to apply the configuration changes:

sudo systemctl restart php7.4-fpm

Step 5. Configure Lighttpd.

Now we edit the Lighttpd configuration file and change it using the Fast CGI:

nano /etc/lighttpd/conf-available/15-fastcgi-php.conf

Find the following lines:

"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",

Next, replaced them with the following lines:

"host" => "",
"port" => "9000",

Save and close the file, then restart the PHP-FPM service to apply the configuration:

lighty-enable-mod fastcgi
lighty-enable-mod fastcgi-php
sudo systemctl restart lighttpd

Step 6. Configure Lighttpd Virtual Host.

Now we create a new virtual host file to test PHP with Lighttpd:

nano /etc/lighttpd/conf-available/example.conf

Add the following lines:

$HTTP["host"] == "" {
    server.document-root = "/var/www/html/"
    server.errorlog      = "/var/log/lighttpd/"

Save and close the file then activate the virtual host with the following command below:

ln -s /etc/lighttpd/conf-available/test.conf /etc/lighttpd/conf-enabled/

Then, create a sample index.php file in the Lighttpd document root directory with the command below:

nano /var/www/html/index.php

Add the following line:


Save and close the file, also set proper permission and ownership with the following command below:

chown -R www-data:www-data /var/www/html/
chmod -R 755 /var/www/html
sudo systemctl restart lighttpd

Once successfully configure the virtual host, open your web browser and verify your website using the URL

Congratulations! You have successfully installed Lighttpd. Thanks for using this tutorial for installing the latest version of the Lighttpd with PHP on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Lighttpd website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button