How to Install Lighttpd with PHP in Ubuntu 20.04

In this article, I will show you how to install the Lighttpd web server with PHP in Ubuntu 20.04 LTS. This tutorial is for beginners who are looking to learn about installing a new web server or want an alternative to Apache and Nginx that provides faster execution of PHP scripts.

How to Install Lighttpd with PHP in Ubuntu 20.04

Most, if not all, Linux fans, particularly those interested in online-based projects and jobs, have come across the notion of web servers. Because there are so many web servers available to the Linux community, you may as well throw a coin or roll a die to discover one that’might’ meet your web-based requirements.

Lighttpd is a web server that is compatible, extremely versatile, quick, and secure. As a result, it is tuned for great performance in every operating system setting.

Furthermore, this web server is incredibly light, requiring very little resources to perform or execute its functional goals, such as processing AJAX applications. This web server is open-source and BSD-licensed, with perfect compatibility with UNIX-like computers.

This guide will lead you through the process of installing and configuring Lighttpd as a web server for your Ubuntu 20.04 operating system.

Table of Contents

Lighttpd is a web server that runs on Ubuntu Linux.

The first thing you should do is make sure your operating system is up to date. On the Ubuntu 20.04 system you’re running, you’ll also need to be a root user or have Sudo access to complete this step.

sudo apt-get update

Run the following command in your Ubuntu terminal to install Lighttpd.

apt-get install lighttpd $ sudo apt-get install lighttpd

The following command will also request the installation of Lighttpd’s extra requirements.

In Ubuntu, install Lighttpd.In Ubuntu, install Lighttpd.

Now that the webserver has been installed, we must start it and allow it to continue operating even after the system has been successfully booted or rebooted.

systemctl start lighttpd $ sudo systemctl start lighttpd systemctl enable lighttpd $ sudo systemctl enable lighttpd

Check the webserver’s status to make sure it’s up and operating.

$ sudo systemctl status lighttpd Check Lighttpd in UbuntuCheck Lighttpd in Ubuntu

If you’re using a UFW firewall, you’ll need to open the ports listed below to allow Lighttpd access.

ufw allow 80 $ sudo ufw allow 443 $ sudo OR $ sudo ufw http allow allow https sudo ufw

To ensure that Lighttpd can serve web pages on your Ubuntu system, go to your web browser and type in your machine’s IP address or localhost.

http://server-ip OR http://localhost Check Lighttpd Page in UbuntuCheck Lighttpd Page in Ubuntu

PHP may be installed on Ubuntu Linux.

The PHP programming language and Lighttpd are quite complementary. We need to setup PHP support under Lighttpd since most web applications use PHP as their fundamental backbone.

As a result, you must first install the PHP-related programs listed below on your Ubuntu OS.

$ sudo apt install php7.4, php7.4-fpm php7.4-mysql php7.4-cli php7.4-curl php7.4-xml Install PHP in UbuntuInstall PHP in Ubuntu

We’ll need to open some configuration files and make a few adjustments to for Lighttpd and PHP to interact.

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

Remove the first listen = /run/php/php7.4-fpm comment. Set the sock value to listen =, as indicated.

Install PHP on Ubuntu.Install PHP on Ubuntu.

The file should be saved and closed.

Open the Lighttpd configuration file below.

$ sudo nano /etc/lighttpd/conf-available/15-fastcgi-php.conf PHP FastCGI Configuration FilePHP FastCGI Configuration File

Replace the highlighted lines with the following to create your final configuration file:

Set up PHP FastCGISet up PHP FastCGI

Close the file after saving the changes.

Enable the following modules to allow Lighttpd and PHP to communicate with one other.

lighty-enable-mod fastcgi $ sudo lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php $ sudo lighty-enable-mod fastcgi-php

The php-fpm and Lighttpd services must now be restarted.

$ sudo systemctl lighttpd php7.4-fpm restart

Create the PHP script below to test Lighttpd’s ability to serve PHP files.

/var/www/html/test.php sudo nano

Just paste the code below into it.

Make Lighttpd the owner of the directory where your PHP web pages will be served.

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

Now go to your web browser and open the test.php file to check whether Lighttpd was able to comprehend it.

http://localhost/test.php or http://your-server-ip/test.php Check PHP Page in UbuntuCheck PHP Page in Ubuntu

You’re ready to evaluate Lighttpd’s performance for your web-based applications now that you’ve installed it and enabled PHP support and setup.

Watch This Video-

Frequently Asked Questions

How do I install Lighttpd on Ubuntu?

A: On Ubuntu, Lighttpd needs to be installed using the following command.
sudo apt install lighty

How do I install Lighttpd on Linux?

A: To install the Lighttpd web server on Linux, you will need to use your package manager. For example, if you are using Ubuntu , type apt-get install lighttpd into a terminal window and press enter.

How do I install lighttpd Tecmint?

First, you need to install the yum package. You can do this by typing in a command such as: yum -y install lighttpd. Once that is done, you are ready to configure it and set it up for your server. The following commands will help guide you through the process of configuring lighttpd Tecmint on Ubuntu 16.