How To Install WordPress On Lighttpd Web Server – Ubuntu 20.04/18.04

Lighttpd is a popular web server known for its fast speed and lightweight. Just like Apache2, it is also very easy to install and use with PHP to run various web applications and content management systems like WordPress.

Today we are going to show the process of installing WordPress on Lighttpd with MySQL and PHP. So, follow the steps below to get started.

Steps to Install and Configure WordPress on Lighttpd Web Server

It doesn’t matter if you are on local server or cloud hosting, the process will be the same for both. Here we are using Ubuntu 20.04, however, one can run it on Ubuntu 18.04 LTS server and other similar operating systems such as Linux Mint, MX Linux and Debian.

Run the system update command

Let system-installed packages reach their latest state by running update and upgrade commands:

sudo apt update
sudo apt upgrade

Install Lighttpd for WordPress and other web applications

As we are using Ubuntu Linux here, so we don’t need to add any third party repository for Lighttpd web server installation. Everything is there on the official repo of this Linux, just run the command below:

sudo apt install lighttpd

Activate and check the status of Lighttpd

To ensure that the web server is automatically declared with system startup, we need to enable it each time. So, run the command below:

sudo systemctl enable lighttpd

Check status:

sudo systemctl status lighttpd

Now open the system browser or on any available PC in your network and type the IP address of the server where you installed the Lighttpd: http://ip-address

Install PHP

The command below not only installs PHP, but also the extensions we would need when using WordPress. However, when installing the same, apache2 will be automatically installed, so we ignore it.

sudo apt-get install php php-cgi php-cli php-fpm php-curl php-gd php-mysql php-mbstring zip unzip apache2-

Enable FastCGI and FastCGI-PHP modules

Now everything is done, just one last thing before confirming that our PHP works perfectly with the Lighttpd web server which enables FastCGI extensions.

sudo lighty-enable-mod fastcgi fastcgi-php

Reload the service for the changes to take effect

sudo service lighttpd force-reload

Download and install MySQL

If you already have the MySQL or MariaDB database, you can skip this step, otherwise install it using the command below:

sudo apt install mysql-server

By default on Ubuntu 20.04 LTS, Mysql version 8 will be available for installation.

Secure installation of MySQL

To make sure our database server is secure and wouldn’t be easily compromised, run the MySQL secure command. This will remove demo users and databases, disable remote root login, and allow you to set up a password for the MySQL root user.

sudo mysql_secure_installation

Create a database for Wordpres

Once you are done securing your MySQL, run the following commands to create a database that we will use with our WordPress instance:

sudo mysql

Create a database that we use to store data for our website based on Wordpres CMS running on Lighttpd. Here in the command below light_word is the name of our database. You can change it with whatever you want.

create database `light_word` character set="utf8";

Now create a user to use with the database created above

create user 'demoh2s'@'localhost' identified by 'password';

the demoh2s is the username in the above command created on our system to access the database. Change the ‘password‘ with the password you want to assign to your MySQL database user.

Finally, give the user full permissions to read, write, modify, and delete data in the database. So, for this race:

GRANT ALL PRIVILEGES ON `light_word`.* to `demoh2s`@localhost;

Exit the MySQL command line:


Download WordPress

Now we need to get the open-source WordPress files we need to set up this CMS on Lighttpd.

cd /tmp

Create a folder in the Lighttpd webroot directory

sudo mkdir /var/www/html/h2s

To note: You can change h2s in the syntax above with the name of the website you are installing WordPress for.

Extract the WordPress files then move to the folder created above:

sudo unzip /tmp/
sudo mv /tmp/wordpress/* /var/www/html/h2s

Now we have a directory inside the web root with a name h2s and all the files we need to use Wordpres inside.

Also give your web user full access to the created folder:

sudo chown -R www-data:www-data /var/www/html/h2s

Configure WordPress on Lighttpd

Finally, go to your browser again and type Server IP Address with the name of the directory where you extracted the WordPress file. If we follow the above steps, the directory name in our case is h2s. So, the will be like this: http://server-ip-address/h2s

Here is the screenshot to get an idea:

MySQL database connection min

Configure Virtual Host on Lighttpd

Now, if you are installing it on a hosting or cloud server and want to use a domain or subdomain with Lighttpd, we need to create a virtual host configuration file for them. So let’s say we want to use for the WordPress instance created above.

To note: Replace with your domain name.

Then create a configuration file for it

sudo nano /etc/lighttpd/

Add the following lines.

$HTTP["host"] =~ "" {
server.document-root = "/var/www/html/h2s"
accesslog.filename = "/var/www/html/h2s/logs/access.log">

In the lines above, replace the Example with your domain name and .com with the TLD you have like .com, .in, .org, etc. After that for /var/www/html/h2s– type the path of the folder where you have WordPress files. If we go through our tutorial, the h2s is the folder where we extracted our files in the webroot.

Now save it.

Similarly, you can create a subdomain configuration file. Once you’ve created all of that, it’s time to add them to Lighttpd’s main config file to tell it that, hey, “here are the files for the specific domain name and you just have to serve them “.

Open the Lighttpd configuration file:

sudo nano /etc/lighttpd/lighttpd.conf

Add your web server’s public IP address. is just, for example, replacing it with your own.

server.bind = ""

Bind lighttpd server to public IP address

Also include your domain configuration file:

include ""

Add virtual host to lighttpd

After changes, save the file and exit. CTRL+Xhurry Yes, then press the Enter key.

Restart Lighttpd:

sudo systemctl restart lighttpd

In this way, we can use multiple domains to retrieve files hosted on a server through the Lighttpd web server. You can learn more about configuring Lighttpd virtual host from this Web page