2 C
Texas
angeloma
Senior Writer and partner

How to install lighttpd web server on Ubuntu 18.04?

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.

0. Prerequisites

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

- Advertisement -

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

1.- Upgrading the system
1.- Upgrading the system

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

2.- Installing MariaDB from the terminal
2.- Installing MariaDB from the terminal

Now you have to perform a configuration process. This is best done with mysql_secure_installation script.

:~# mysql_secure_installation

3.- Configuring MariaDB
3.- Configuring MariaDB

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

4.- This is the easiest way to install lighttpd
4.- This is the easiest way to install Lighttpd

And then you enable the service to start with the system.

:~# systemctl enable lighttpd
:~# systemctl start lighttpd

5.- Enabling lighttpd service
5.- Enabling lighttpd service

In order to avoid problems between Lightppd and the firewall, run:

:~# ufw allow 80/tcp
:~# ufw reload
:~# ufw enable

6.- Setting some firewall rules
6.- Setting some firewall rules

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.

7.- lighttpd default page
7.- lighttpd default page

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

8.- Installing PHP
8.- Installing PHP

Next, edit the file /etc/php/7.2/fpm/pool.d/www.conf

:~# nano /etc/php/7.2/pool.d/www.conf

Change the line”listen” to 127.0.0.1:9000.

9.- Editing the PHP file configuration
9.- Editing the PHP file configuration

Next, edit the file /etc/lighttpd/conf-available/15-fastcgi-php.conf too.

:~# nano /etc/lighttpd/conf-available/15-fastcgi-php.conf

And change:

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

To:

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

10.- Editing the PHP configuration file for PHPCGI
10.- Editing the PHP configuration file for PHP CGI

Finally, enable the FastCGI and FastCGI-PHP modules:

:~# lighty-enable-mod fastcgi
:~# lighty-enable-mod fastcgi-php

11.- Enabling the PHP modules
11.- Enabling the PHP modules

Restart Lighttpd:

:~# 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();
?>

12.- Creating a php file for test
12.- Creating a PHP file for test

Change the permissions:

:~# chown -R www-data:www-data /var/www/html/
:~# chown -R 755 /var/www/html/

13.- Changing the permissions to folder
13.- Changing the permissions to the folder

Finally, open your web browser and go to http://IP_SERVER/t.php. If you see this, everything is working.

14.- PHP info
14.- PHP info

Conclusion

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.

 

 

 

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article