In this guide, we are going to explain the steps in installing Lighttpd, PHP, and MySQL on Ubuntu 16.04/18.04.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo apt-get update && sudo apt-get upgrade

Step 1: Install Lighttpd
Check our guide on Installing Lighttpd on Ubuntu 16.04/18.04

Step 2: Install MySQL
Check our guide on Installing MySQL on Ubuntu 16.04/18.04

Ensure that MySQL server is running by checking the status with the following command:

sudo systemctl status mysql

Step 3: Install PHP
Issue the command below to install PHP and its related packages from the apt repositories:

sudo apt-get -y install php7.3 php7.3-cgi php7.3-mysql

Step 4: Configure Lighttpd
After installing Lighttpd, PHP 7 and MySQL, there are some configurations which we have to carry out in order to correctly combine the packages to produce the desired results.

First, we need to enable the basic PHP modules by issuing the commands below:

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

Restart Lighttpd to load the configurations.

sudo systemctl restart lighttpd.service

The next step is to check that Lighttpd and PHP are working correctly. We can test this using a PHPInfo file.

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

Enter the following content:

<?php phpinfo(); ?>

Next, visit your server's IP address on the browser or your domain name if you have one followed by /phpinfo.php: