In this article, we will show you how to install Lighttpd web server on an Ubuntu 18.04 VPS with PHP and MariaDB support. Lighttpd is a free, open-source, secure, and standards-compliant web server designed for high-performance environments. Compared to other alternative web-servers, Lighttpd consumes very few resources and capable of serving large loads. It is commonly used for high traffic sites like YouTube.
Let’s begin with the installation.
- For the purposes of this tutorial, we will use one of our Ubuntu 18.04 Cloud VPSes.
- Full SSH root access (our servers come with root access included) or a user with sudo privileges is also required.
Step 1: Connect via SSH and Update the OS
Connect to your server via SSH as the root user using the following command:
ssh [email protected]_ADDRESS -p PORT_NUMBER
Remember to replace “IP_ADDRESS” and “PORT_NUMBER” with your server’s respective IP address and SSH port number (the default is 22).
Before starting with the installation, you will need to update your OS packages to their latest versions. It’s easy to do, and it won’t take more than a few minutes.
You can do this by running the following command:
apt-get update apt-get upgrade
Once the updates are completed, we can move on to the next step.
Step 2: Install Lighttpd
Lighttpd is available within Ubuntu’s default software repositories – this makes installing Lighttpd as simple as installing a package. So, run the following command to install Lighttpd web server:
apt-get install lighttpd
Once the Lighttpd packages have been installed, we can start and enable the service to automatically start at boot.
systemctl start lighttpd systemctl enable lighttpd
To check the status of the service run the following command:
systemctl status lighttpd
● lighttpd.service - Lighttpd Daemon Loaded: loaded (/lib/systemd/system/lighttpd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-07-17 05:42:39 UTC; 38s ago Main PID: 12965 (lighttpd) Tasks: 1 (limit: 1114) CGroup: /system.slice/lighttpd.service └─12965 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf Jul 17 05:42:39 ubuntu1804 systemd: Starting Lighttpd Daemon... Jul 17 05:42:39 ubuntu1804 systemd: Started Lighttpd Daemon.
Open your favorite web browser and enter your server’s IP Address. It will be redirected to the default Lighttpd web page.
You’re technically finished with installing Lighttpd, however the next steps are very beneficial to maximizing the potential of your web server.
Step 3: Install MariaDB
If you need MariaDB database support with your Lighttpd web server, we can easily install the MariaDB database server using the following command:
apt-get install mariadb-server
Once the installation has been completed, we can start the service and enable it to start on server boot with the following commands:
systemctl start mariadb systemctl enable mariadb
We can then check the status of the service by running the following command:
systemctl status mariadb
If everything is fine, the service should already be started, and you should get the following output:
● mariadb.service - MariaDB 10.1.40 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-07-17 05:47:57 UTC; 50s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 14829 (mysqld) Status: "Taking your SQL requests now..." Tasks: 27 (limit: 1114) CGroup: /system.slice/mariadb.service └─14829 /usr/sbin/mysqld Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: information_schema Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: mysql Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: performance_schema Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: Phase 6/7: Checking and upgrading tables Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: Processing databases Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: information_schema Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: performance_schema Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: Phase 7/7: Running 'FLUSH PRIVILEGES' Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: OK Jul 17 05:48:00 ubuntu1804 /etc/mysql/debian-start: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
Step 4: Install PHP 7.2 and PHP Extensions
To install PHP along with all of its necessary extensions, run the following command:
apt-get install php7.2 php7.2-fpm php7.2-mysql php7.2-cli php7.2-curl php7.2-xml php7.2-mbstring php7.2-gd
Once PHP 7.2 has been installed, we need to enable PHP-FPM and FastCGI for Lighttpd.
Open the file
/etc/php/7.2/fpm/pool.d/www.conf using your preferred text editor:
Find the following line:
listen = /run/php/php7.2-fpm.sock
Replace it with
listen = 127.0.0.1:9000
Save and close the file.
Open the FastCGI configuration file
/etc/lighttpd/conf-available/15-fastcgi-php.conf using your preferred text editor:
Find the following lines:
"bin-path" => "/usr/bin/php-cgi", "socket" => "/var/run/lighttpd/php.socket",
Then replace those values with
"host" => "127.0.0.1", "port" => "9000",
Save and close the file.
Then, enable the FastCGI and FastCGI-PHP modules with the following commands:
lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php
Restart Lighttpd and PHP7.2-FPM to apply all the configuration changes:
service lighttpd force-reload systemctl restart php7.2-fpm
That’s all there is to it – in this tutorial, we learned how to install Lighttpd on an Ubuntu 18.04 Cloud VPS, as well as how to enable MariaDB, PHP and PHP-FPM with FastCGI support in Lighttpd.
Of course, you don’t have to install Lighttpd on Ubuntu 18.04 if you use one of our Managed Ubuntu Cloud VPS services, in which case you can simply ask our expert Linux admins to install and set up Lighttpd for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Lighttpd on Ubuntu 18.04, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.