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 light weight. Just like Apache2, it is also very easy to install and use with PHP to run various web applications and content management systems such as WordPress.

Here today we will 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 a local server or cloud hosting, the process will be the same for both. Here we are using Ubuntu 20.04, however, we can run it on Ubuntu 18.04 LTS server and other similar operating systems like Linux Mint, MX Linux and Debian.

Run the system update command

Let the system installed packages reach their last state by running the 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 installing Lighttpd web server. 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 make sure that the web server is automatically declared with system startup, we have to activate it every time. So, run the command below:

sudo systemctl enable lighttpd

Check the condition:

sudo systemctl status lighttpd

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

Install PHP

The command below installs not only PHP but also the plugins that we would need when using WordPress. However, when installing the same, apache2 will be installed automatically, 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-

Activate the FastCGI and FastCGI-PHP modules

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

sudo lighty-enable-mod fastcgi fastcgi-php

Reload the service to apply the changes

sudo service lighttpd force-reload

Download and install MySQL

If you already have this 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, version 8 of Mysql will be available for installation.

Secure installation of MySQL

To make sure that our database server is secure and would not be easily compromised, run the MySQL secure command. This will remove demo users and databases, disable the remote root login, and allow you to configure a password for the MySQL root user.

sudo mysql_secure_installation

Create a database for Wordpres

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

sudo mysql

Create a database that we use to store data from 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, grant full permissions to the user 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:

exit

Download WordPress

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

cd /tmp
wget https://wordpress.org/latest.zip

Create a folder in the webroot directory of Lighttpd

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/latest.zip
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 Internet user all access to the created folder:

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

Install WordPress on Lighttpd

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

Here is the screenshot to give you an idea:

Connection to the MySQL database min

Installing WordPress on Lighttpd

Configure virtual host on Lighttpd

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

To note: Replace example.com with your domain name.

Then create a configuration file for it

sudo nano /etc/lighttpd/example.com.conf

Add the following lines.

$HTTP["host"] =~ "example.com" {
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 such as .com, .in, .org, etc. After that for /var/www/html/h2s– type the path of the folder where you have the WordPress files. If we follow our tutorial, the h2s is the folder where we extracted our files in the web root.

Now save it.

In the same way, we 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 need to serve them only”.

Open the Lighttpd configuration file:

sudo nano /etc/lighttpd/lighttpd.conf

Add the public IP address of your web server.

36.0.1.106 is just, for example, replacing it with your own.

server.bind = "36.0.1.106"

Bind the lighttpd server to the public IP address

Also include your domain configuration file:

include "example.com.conf"

Add a virtual host to lighttpd

After the changes, save the file and exit. Ctrl + X, hurry 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 delivered through the Lighttpd web server. You can read more about configuring Lighttpd virtual host from this Web page


Source link

Leave a Reply

Your email address will not be published. Required fields are marked *