How to Install WordPress on OpenLiteSpeed

How to Install WordPress on OpenLiteSpeed

OpenLiteSpeed is one of the best servers available for WordPress. Any WordPress site will perform like a rocket when paired with an OLS server.

OpenLiteSpeed offers a fast and secure server software that will make your WordPress site secure and fly. It also has support for Apache rewrite rules.

In this tutorial, I will show you how to install WordPress on OpenLiteSpeed server and optimize it. This tutorial assumes that you already have installed OLS.

Pre-requisites

Before installing WordPress, we have to install some of the other softwares it needs. Some of them are: the OLS server itself, MariaDB, PHP etc.

1) Installing MariaDB Server

MariaDB is a popular open-source alternative to MySQL. Actually, it’s a fork of MySQL and in some ways, its better. Use the following commands to install MariaDB on your server:

sudo apt update
sudo apt install mariadb-server

After installing MariaDB, we have to secure it. Secure it by the following command:

sudo mysql_secure_installation

This will open a wizard. Use the following answers as shown bellow:

Change the root password: N
Remove anonymous user: Y
Disallow root login remotely: Y
Remove test database and access to it: Y
Reload Privilege Table Now: Y

Now, MariaDB is installed and secured.

Now, we will make a database. Enter MariaDB with the following command:

sudo mysql

Then use the following commands to create a user and grant all permissions to it.

mysql > CREATE DATABASE wordpress;
mysql > GRANT ALL ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'password';

Next, flush privilege and exit from MariaDB

mysql > flush privileges;
mysql > exit;

Your database is ready for installing WordPress.

2) Installing required PHP Extensions

WordPress is written in PHP. So, it needs PHP to work. Install the required extensions with the following command:

sudo apt install lsphp74-common lsphp74-curl lsphp74-imap lsphp74-json \
lsphp74-mysql lsphp74-opcache lsphp74-imagick lsphp74-memcached lsphp74-redis

Now, you have the required PHP extensions.

3) Configuring OpenLiteSpeed Server

Before we can install WordPress, we need to configure a few things first. We need to set the correct PHP version, enable the rewrite module and more.

First, we will configure OLS to use lsphp74 as PHP processor instead of the default one.

To do this, go to Server Configuration > External App and click on the edit icon as shown below in the picture.

OpenLiteSpeed PHP Processor

Here, we need to change a few things as mentioned below:

  • Replace lsphp with lsphp74
  • Replace uds://tmp/lshttpd/lsphp.sock with
    uds://tmp/lshttpd/lsphp74.sock
  • Replace lsphp73/bin/lsphp with
    $SERVER_ROOT/lsphp74/bin/lsphp
lsphp74

After making the changes, click on the save icon at the top right as shown in the above screenshot.

Next, we will configure the rewrite module, which is a feature which is needed by WordPress. Go to Virtual Hosts and click on the view icon.

Edit Virtual Host

Click on the General tab and edit the General Options by clicking on the edit icon at the top-right corner.

Edit General Options

In the Document Root field, type $VH_ROOT/html/wordpress and save it by clicking on the save button at the top right corner.

Document Root

Again, go back to the General tab in Virtual Hosts and and edit the Index Files section.

Index Files

In the Index Files field, add index.php at the beginning of the field and save it by clicking on the save button at the top-right corner.

index.php Index Files

Next, open the Rewrite tab in the Virtual Hosts configuration page and edit the Rewrite Control options.

Rewrite Control

Change Enable Rewrite and Auto Load from .htaccess to Yes and save it by clicking on the save button at the top-right corner.

Rewrite Control

Once everything is configured, perform a Graceful Restart by clicking the Graceful Restart icon at the top-right corner to apply the changes and restart the server.

Graceful Restart

This completes our OpenLiteSpeed configuration for WordPress.

4) Downloading and Extracting WordPress

Now that we have configured OLS for WordPress, we need to download and install WordPress.

Go to /usr/local/lsws/Example/html by using the command below:

cd /usr/local/lsws/Example/html/

Then, download the latest version of WordPress by using the command below:

wget https://wordpress.org/latest.tar.gz

Extract the compress file:

tar xvfz latest.tar.gz

5) Setting Up File Ownership and Permissions

Setting up the correct file/folder ownership and permissions is the difference between completely securing your WordPress site and getting hacked within a few mins. It also fixes problems regarding installing themes and plugins.

Set 750 permission to the directories and 640 to the files. Use the following commands to accomplish this:

sudo find /usr/local/lsws/Example/html/wordpress/ -type d -exec chmod 750 {} \;
sudo find /usr/local/lsws/Example/html/wordpress/ -type f -exec chmod 640 {} \;

The picture below show how permissions work:

Linux Permissions

Once you have set up the correct permissions, you are all se to install WordPress!

ALSO READ – How to Install WordPress on Hostinger Easily

6) Installing WordPress

Now, we are ready to install WordPress. You will do this by going to the IP address of your server OR by going to the domain (if you have set up one).

Select the language and click on Continue.

Select WordPress Language

In the next screen, it will ask you to keep your database credentials ready. After you have them, click on the Let’s go! button.

Let's go WordPress

In the next screen, fill up the following fields with correct info:

  • Database Name
  • Username
  • Password
  • Database Host
  • Table Prefix

Fill all of these fields according to screenshot below:

WordPress Configuration

Once you have filled them up with the correct information, click on the Submit button.

After WordPress successfully checks for database connection, click on Run the installation button to set up your WordPress site.

Run the installation WordPress

Next, you will be asked to enter a few details about your site like creating an admin user, admin password, admin email etc. Also, you will be asked if you want the site to be indexed by search engines or not.

Site Details WordPress

After you have entered everything correctly, click on Install WordPress to start the installation of WordPress.

After installation is completed, you will be redirected to the login page. Login using the username and password that you selected during installation. After you login, you will get access to your site’s dashboard.

WordPress Dashboard

7) Configuring SSL Certificates

Till now, you have installed and configured WordPress. Next, we will install an SSL certificate on the server which will secure the communication between the web server and the users.

We will do this by using something called certbot. Here is how you can install it.

First, update the packages on your server:

sudo apt update

Then, install certbot from the repository:

sudo apt install certbot

Next, we will use certbot to issue an SSL certificate. Before we can do that, we need to have a domain name along with the www subdmain that is pointed to the server’s public IP. After that, we will use this command:

sudo certbot certonly --webroot

When you run this, you will be asked a few questions.

  • Enter Email Address
  • Accept the Terms of Service
  • Share your Email with EFF
  • Enter Domain Name
  • Input the Web root

After answering these, the certificate will be issued. You can find the certificate in the /etc/letsencrypt/live/<your-domain>/ directory.

Next, we need to configure OLS to use the SSL certificates. Navigate to the Virtual Host configuration and open the SSL tab. Edit SSL Private Key and Certificate.

SSL Certificate

Type the following in the fields:

Private Key File: /etc/letsencrypt/live/<your-domain>/privkey.pem
Certificate File: /etc/letsencrypt/live/<your-domain>/fullchain.pem
Chained Certificate: Yes
CA Certificate Path: /etc/letsencrypt/live/<your-domain>/fullchain.pem
CA Certificate File: /etc/letsencrypt/live/<your-domain>/fullchain.pem

After that, save it and gracefully restart the server.

Save and Graceful Restart SSL

Now, we will add a new SSL listener. We will do this by going to the Listeners option.

Add New Listener

Fill these values in the fields:

Listener Name: SSL
IP Address: ANY
Post: 443
Binding:
Enable REUSEPORT: Not Set
Secure: Yes

Once done, save the settings.

OLS 443 Listener

Next, we will configure virtual host mapping to the SSL listener. Click on view beside the listener.

SSL Listener View

Add a new virtual host mapping.

Add Virtual Host

Type in your domain name and save by clicking on the save button at the top-right corner.

Virtual Host Domains

After completion of all of these steps, gracefully restart the server.

To improve the performance of WordPress, you can install OpenLiteSpeed cache plugin.

You can also install memcached with the following command:

sudo apt-get install memcached

Congratulations! You have successfully installed and secured WordPress on an OpenLiteSpeed server.

I hope that this tutorial has been really helpful. If you have any queries or suggestions, please let me know in the comments down below.

ALSO READ: 10 Ways to Secure Your WordPress Site

Leave a Reply

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