On this site, we have talked a lot about web servers as it is a very popular topic in the development of current applications. In addition, configuring them is a delicate and vital task for an organization. On the other hand, you have to be efficient in the management of computer resources, so today I will show you how to install Lighttpd in Ubuntu 18.04.
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 Ubuntu 18.04 with Lighttpd is a safe bet if you want a fast, efficient and secure web server. Go for it.
The idea is to install a complete web server using Lighttpd, PHP, and MariaDB in Ubuntu 18.04. It’s not complicated but you should keep in mind the following:
- It is advisable to have some knowledge about the use of the terminal.
- Have root access to perform the commands.
- Have a computer with Ubuntu 18.04.
1.- Upgrade the system
It’s a good idea to start these tutorials by updating the system, making sure you have the latest security patches for your system. Open a terminal and run:
:~$ sudo -i
After entering the password you will be the root user. Next:
:~# apt update && apt upgrade
With this, you will have updated your system.
2.- Install MariaDB
MariaDB is a fork of Mysql. It is fully compatible with the former and is the most recommended for its experience of use. However, despite this, it is very powerful and reliable.
To install it, run:
:~# apt install mariadb-server
Now you have to perform a configuration process. This is best done with
After setting the root password, you will be asked some configuration questions. I will answer Y, N, Y, Y.
3.- Install Lighttpd
The easiest and most direct way to install Lighttpd on Ubuntu 18.04 is to do it from the official repositories.
:~# apt install lighttpd
And then you enable the service to start with the system.
:~# systemctl enable lighttpd :~# systemctl start lighttpd
In order to avoid problems between Lightppd and the firewall, run:
:~# ufw allow 80/tcp :~# ufw reload :~# ufw enable
To check the installation, go to your web browser and try to access to
http://IP_SERVER. If you see this then everything is OK.
4.- Install PHP
A web server needs a programming language to interpret and execute the applications built, so install PHP.
:~# apt install php7.2 php7.2-fpm php7.2-mysql php7.2-cli php7.2-curl php7.2-xml
Next, edit the file
:~# nano /etc/php/7.2/pool.d/www.conf
Change the line”listen” to 127.0.0.1:9000.
Next, edit the file
:~# nano /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",
Finally, enable the FastCGI and FastCGI-PHP modules:
:~# lighty-enable-mod fastcgi :~# lighty-enable-mod fastcgi-php
:~# systemctl restart lighttpd
5. Testing the installation
To verify that everything is working, make a .php file in the root directory of the server, i.e. in
/var/www/html. I’ll call it
t.php. Put on it this:
<?php phpinfo(); ?>
Change the permissions:
:~# chown -R www-data:www-data /var/www/html/ :~# chown -R 755 /var/www/html/
Finally, open your web browser and go to
http://IP_SERVER/t.php. If you see this, everything is working.
To install Lighttpd only basic knowledge about the use of the terminal and configuration files is required because it is really simple. Being this a web server oriented to simplicity and speed we find simple files to configure.
We want to know about you, have you used this program before? you have been using the tutorial? what about your experience with PHP and Lighttpd? Let us know in the comments.
Please share this article on your social networks.