How To Install the LLMP Stack on Ubuntu 18.04 VPS Server or Dedicated Server

Lighttpd which is part of LLMP (Linux, Lighttpd, MySQL, and PHP) stack is an open source web server that runs several sites across the globe with a focus on increasing performance and light moment footprint. With the help of MySQL, and PHP, Lighttpd acts as a strong alternative to the robust LAMP stack.

This article will take you through the process of installing Lighttpd, MySQL, Linux, and PHP to ensure your cloud server is up and running.


  • This tutorial assumes that you already have Ubuntu VPS installed with root privileges.
  • We will use MariaDB which is fully compatible with MySQL management system and can be used as a full drop-in replacement.

Let’s get started.

Step 1: Installing MariaDB

Start by updating the repository index on your system:

$ sudo apt update

Then, install the MariaDB server by running the command below:

$ sudo apt -y install mariadb-server

MariaDB should start running immediately. If it fails to start, run the command below:

$ sudo systemctl start mariadb

Make sure you restart MariaDB every time you reboot your system. Then run the command below and press Enter:

$ sudo systemctl enable mariadb

Now, secure the MariaDB server using the mysql_secure_installation command.

Once you’re done, start installing Lighttpd.

Step 2: Installing Lighttpd

To install Lighttpd, run the command below:

$ sudo apt install -y lighttpd

Now start Lighttpd service once the installation is done.

$ sudo systemctl start lighttpd

Step 3: Firewall

For Lighttpd to work, you need to allow HTTP requests to pass through the firewall. To do so, run the commands below:

$ sudo ufw allow http
$ sudo ufw reload
$ sudo ufw enable

Now, open a new web browser and go to:


A Lighttpd page should appear to show that the service has been installed on your server.

How To Install the LLMP Stack on Ubuntu 18.04 VPS Server or Dedicated Server

Now, restart your system to ensure Lighttpd is updated.

$ sudo systemctl enable lighttpd

Step 5: Installing PHP – FPM

Lighttpd requires the services of PHP FastCGI to help in setting up PHP. PHP is important for websites that receive high traffic. To install PHP, run the command below:

$ sudo apt install -y php-fpm php-mysql php-cli

Make sure you edit the php.ini file with the command below:

$ sudo nano /etc/php/7.2/fpm/php.ini

Now, set cgi.fix_pathinfo to 1 with the command below:


By default. PHP points to the UNIX socket/run/php/php7.2-fpm.sock. Go ahead and edit the “/etc/php/7.2/fpm/pool.d/www.conf” file to ensure PHP listens to TCP socket.

This can be done by running the command below:

$ sudo nano /etc/php/7.2/fpm/pool.d/www.conf

Next, edit and change the listen details.


listen = /run/php/php7.2-fpm.sock


listen =

Now restart PHP service.

$ sudo systemctl restart php7.2-fpm

Go ahead and edit the file 15-fastcg-php.conf as shown below:

$ sudo nano /etc/lighttpd/conf-available/15-fastcgi-php.conf

Search for the following entries and edit them.


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


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

Now, enable both FastCGI and FastCGI-PHP components by running the following commands:

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

Then, restart Lighttpd:

$ sudo systemctl restart lighttpd

Step 6: Enabling PHP Service on Virtual Host

The next step is to create and enable a virtual host on Lighttpd server. Use the details below:

Server Name: www.hostadvice.local

Document root: /var/www/html/www.hostadvice.local

Go to /etc/lighttpd/conf-available/ and create a new configuration file known as www.hostadvice.local.conf.

$ sudo nano /etc/lighttpd/conf-available/www.hostadvice.local.conf

Add the information below:

$ sudo HTTP["host"] == "www.hostadvice.local" {   ### Domain URL
server.document-root = "/var/www/html/www.hostadvice.local"   ### Document root

Now, enable the virtual host:

$ sudo ln -s /etc/lighttpd/conf-available/www.hostadvice.local.conf /etc/lighttpd/conf-enabled/

Since PHP is enable, the next step is to test whether it’s working on the virtual host.

Step 5: Testing PHP Service on Virtual Host

Start by creating a root directory for the current domain using the command below:

$ sudo mkdir /var/www/html/www.hostadvice.local

To test PHP, place a .php file on the root document on the virtual host.

$ sudo nano /var/www/html/www.hostadvice.local/index.php

This will open a file labeled index.php. Now, copy and paste the line below into the index.php file:

<?php phpinfo(); ?>

Now, set the permission with the following command:

$ chown -R www-data:www-data /var/www/html/

Restart PHP service to apply these changes:

$ sudo systemctl restart lighttpd
$ sudo systemctl restart php7.2-fpm

Open a new browser and enter your domain. In this case, the domain is


You should see a page that looks like this:

How To Install the LLMP Stack on Ubuntu 18.04 VPS Server or Dedicated Server

The screenshot above indicates that PHP is functioning well through FastCGI shown in the API line on your server.

Now, scroll down to see the available PHP modules that are active.

Scroll further down to see the information about MySQL.

How To Install the LLMP Stack on Ubuntu 18.04 VPS Server or Dedicated Server


That’s it! Now you have simplified guide with all you need to install the LLMP stack on 18.04 VPS successfully. Now, you can start using your LLMP based web server with ease.


Check out the top 3 VPS services:

  • Check the recommendations for the best VPS and get a suitable one.

Was this article helpful?