Lighttpd is a fast, secure and reliable web server optimized for a high-performance environment. It is open-source software and uses a BSD license. It works on UNIX based systems like Linux or BSD. The Lighttpd web server consumes very fewer server resources compared to other web servers like Apache and Nginx.
Steps to Install Lighttpd Web Server on Ubuntu
- It is advisable to have some knowledge of Ubuntu web server.
- You must have root access to perform the commands.
- You must have basic knowledge of using the terminal.
1. Update and Upgrade the Server
Make sure your server is updated and have all the latest security updates. To perform the updates, run:
apt update && apt upgrade
2. Install MariaDB
MariaDB is a fork of Mysql. It is very powerful and reliable. To install MariaDB, run:
sudo apt install mariadb-server
Now we need to securely configure MariaDB by running the following command:
Verify that MariaDB is operational
Once you are done installing MariaDB, run:
mysql -u root -p
When prompted, enter your password. You will see the output similar to the following:
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is XXXX Server version: 5.5.X Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
To start and stop MariaDB, run the following command:
service mysql start
service mysql stop
3. Install Lighttpd
The easiest way to install Lighttpd on Ubuntu 18.04 is to do it from the official repository. To install, run:
apt install lighttpd
To enable the service, run:
sudo systemctl enable lighttpd
To start the service, run:
sudo systemctl start lighttpd
In order to run Lighttpd smoothly, allow HTTP connections by running the following command:
sudo ufw allow 80/tcp
sudo ufw reload
sudo ufw enable
You can check the Lighttpd web server installation by entering the IP Address of your server.
4. Install PHP
To run any web application, a programming language is required to interpret and execute the web application code. In our tutorial, we are installing PHP. It can be installed by running the following command:
sudo apt install php7.2 php7.2-fpm php7.2-mysql php7.2-cli php7.2-curl php7.2-xml
Next, edit the file
sudo vim /etc/php/7.2/pool.d/www.conf
Change the line
”listen” to 127.0.0.1:9000.
5. Adjusting the PHP Configuration
Edit and configure
/etc/lighttpd/conf-available/15-fastcgi-php.conf too file.
sudo vim /etc/lighttpd/conf-available/15-fastcgi-php.conf
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",
"host" => "127.0.0.1",
"port" => "9000",
6. Configure PHP for PHP CGI
Now, enable the FastCGI and FastCGI-PHP modules:
sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php
Now restart the Lighttpd by running:
sudo systemctl restart lighttpd
7. Check the installation
To verify that everything is working properly.
Create a test.php file in the root directory of the server, i.e. in
/var/www/html and inside this file add the following code:
<?php phpinfo(); ?>
8. Changing Permissions
sudo chown -R www-data:www-data /var/www/html/ sudo chown -R 755 /var/www/html/
Finally, open your web browser and enter
You will PHP version info page that confirms everything is working properly.
I hope you will find this tutorial useful.
If you have any question or need help with Lighttpd web server installation, feel free to ask in the comment section below.