29.9 C
Texas
angeloma
Senior Writer and partner

How to install lighttpd on Debian 10?

So, today I will show you how to install Lighttpd in Debian 10.

Lighttpd is a “secure, fast, compatible and very flexible” web server optimized for high-performance environments. It consumes very few resources compared to other web servers and especially fast for running AJAX applications. It is also open source and uses a BSD license and works on UNIX-like systems, such as Linux or BSD.

Combining Debian 10 with Lighttpd is a safe bet if you want a fast, efficient and secure web server. Go for it.

Install Lighttpd on Debian 10

Fortunately, Lighttpd is available from the official Debian repositories. So, the installation only comes down to one command.

- Advertisement -

So, open a terminal session or connect to your server remotely and run the following command:

:~$ sudo apt install lighttpd
1.- Install Lighttpd on Debian 10
1.- Install Lighttpd on Debian 10

In case you do not have sudo enabled, you can log in as root, or learn how to enable it with our post manager:

How to enable sudo on Debian 10?

Once it has been installed, we will be able to check the operation of it, opening a web browser and going to http://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.

If we manage to see this image, it means that everything is in order.

2.- Lighttpd working on Debian 10
2.- Lighttpd working on Debian 10

Now, let’s install PHP.

Enabling the PHP support to Lighttpd

Lighttpd is up and running, but let’s be honest, a web server that doesn’t have at least PHP is not much use to us. So we’ll install and configure PHP and 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
3.- Install PHP on Debian 10
3.- Install PHP on Debian 10

And then we will do the settings.

To start with, you have to modify the listen parameter in the PHP-fpm configuration file.

:~$ sudo nano /etc/php/7.3/fpm/pool.d/www.conf
listen = 127.0.0.1:9000
4.- Configuring PHP to work with Lighttpd
4.- Configuring PHP to work with Lighttpd

Save the changes and close the file.

Now, another configuration file needs to be modified. In this case, it is /etc/lighttpd/conf-available/15-fastcgi-php.conf and in it, you have to change the following:

:~$ sudo nano /etc/lighttpd/conf-available/15-fastcgi-php.conf
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",

To

"host" => "127.0.0.1",
"port" => "9000",
5.- Adding PHP support to Lighttpd
5.- Adding PHP support to Lighttpd

After saving the changes and closing the file, PHP-fpm must be enabled in Lighttpd.

:~$ sudo lighty-enable-mod fastcgi
 Enabling fastcgi: ok
:~$ sudo lighty-enable-mod fastcgi-php
 Enabling fastcgi-php: ok

Then, restart lighttpd and php-fpm.

:~$ sudo systemctl restart lighttpd
:~$ sudo systemctl restart php7.3-fpm

Now, we are going to test PHP.

Test PHP and Lighttpd on Debian 10

The best way to test the installation is to create a PHP file and open it from the web browser and check that it runs.

So, let’s create one.

:~$ sudo nano /var/www/html/test.php

And add the following:

<?php
phpinfo();
?>

Save the changes and close the file.

Also, it’s a good idea to change the permissions of the Lighttpd root folder so that all files run correctly:

:~$ sudo chown -R www-data:www-data /var/www/html/
:~$ sudo chown -R 755 /var/www/html/

Now, open your web browser and go to http://your-server/test.php or if the installation is local http://localhost/test.php and you should see this image.

6.- PHP and Lighttpd working
6.- PHP and Lighttpd working

So, enjoy it.

Conclusion

Lighttpd stands out for being very light in the execution of web applications. So it can serve us for many interesting things in our daily work on a server. Today we have learned to install it on a server with Debian 10 and we have also added support for PHP.

Please share this post and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article