Tutorials How to install WordPress on OpenLiteSpeed

How to install WordPress on OpenLiteSpeed

WordPress flies like a skyrocket when installed with the perfect speed-optimised OpenLiteSpeed server stack. Over 30% of the websites in the world use WordPress as CMS which defines how powerful is it to design, develop and manage a business website, blog or portal.

OpenLiteSpeed offers a fast and secure environment for running WordPress. OpenLiteSpeed understands apache rewrite tools and you can install multiple PHP processors for different sites as well.

In this tutorial, we will optimise the OpenLiteSpeed server to host a WordPress site and then install the latest WordPress on the server.

Pre-requisites

Before you can start installing WordPress, you need to have an OpenLiteSpeed server up and running. If you are new to OpenLiteSpeed, check out our tutorial on how to deploy the OpenLiteSpeed server.

Once your OpenLiteSpeed server is set up, you can get started with installing WordPress. In this guide, we’ll go over the process for:

  1. Installing MariaDB database
  2. Creating a database and the database user
  3. Installing the required PHP extensions
  4. Configuring OpenLiteSpeed
  5. Downloading and extracting WordPress
  6. Setting the right file ownership and permissions
  7. Installing WordPress itself
  8. Setting up SSL certificates to enable HTTPS

Begin by following the instructions in the next section to install MariaDB.

Installing MariaDB server

MariaDB is a popular open-source alternative to MySQL database and is conveniently available in the standard repositories. First, update the packages list on the server with the command below.

sudo apt update

Once the packages list has been updated, run the following command to install the MariaDB server and MariaDB client on your server. You’ll be prompted to confirm to use storage space. Type Y and press Enter to continue with the installation.

sudo apt install mariadb-server

Next, perform the secure installation of MySQL on your server with the following command.

sudo mysql_secure_installation

The command prompt will take you through the wizard containing the questions below. Answer each of them as below:

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 that MariaDB is installed and configured, we can create the first database.

Enter into the MySQL client by running the next command.

sudo mysql

Then use the following commands to create a database and grant all permissions on that database to a new database user account.

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

Flush the privilege table and exit from the mysql shell.

mysql > flush privileges;
mysql > exit;

Your database is then all set for installing WordPress at a later step.

Installing required PHP extensions

WordPress works on the top of PHP and SQL. To run WordPress on a server seamlessly, install the following required PHP extensions.

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

Configuring OpenLiteSpeed

Next, you need to configure the OpenLiteSpeed server to host your WordPress site. It requires you to set the right version of PHP processor, enable the rewrite module and several other features.

Configure your server to use lsphp74 as PHP processor instead of the default PHP processor.

Go to Server Configuration > External App and click the edit icon as shown below.

OpenLiteSpeed SAPI app

Here, you can configure your server to use any specific PHP processor. For this tutorial, we will use lsphp74.

  • 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

Configuring OpenLiteSpeed PHP

After you make the changes, click the save icon on the top right corner of the panel as shown in the above screenshot.

Moving next to configure the rewrite module which is an essential requirement for WordPress feature. Go to the Virtual Hosts and click on the view icon.

Editing OpenLiteSpeed virtual host

Click on the General tab and edit the General options with the edit icon at the top right corner.

Editing OpenLiteSpeed general virtual host

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

OpenLiteSpeed general virtual host

Then again on the General tab of Virtual Hosts configuration, click the edit icon next to Index Files section.

OpenLiteSpeed general virtual host

In the Index Files field, add index.php at the begin of the section. Then click the save button at the top right corner.

Setting OpenLiteSpeed virtual host index

Next, go to the Rewrite tab of the Virtual Hosts configuration view and edit the Rewrite Control options.

Enabling OpenLiteSpeed virtual host rewrites

Set Enable Rewrite and Auto Load from .htaccess to Yes and click save icon at the top right corner.

OpenLiteSpeed rewrite controls

Once you’ve configured the OpenLiteSpeed server, Click the gracefully restart icon to apply the changes.

Restarting OpenLiteSpeed web server

Downloading and extracting WordPress

Now that our server is configured to host WordPress, you should download and install WordPress.

Navigate to the virtual host root which is /usr/local/lsws/Example/html

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

Then download the latest version of WordPress using the wget command below.

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

Lastly, extract the zipped file. This will create a directory called ‘wordpress’ in /usr/local/lsws/Example/html

tar xvfz latest.tar.gz

Setting up the files ownership and permissions

Setting up the right ownership of files and folders will make sure that you do not encounter problems while installing or downloading new themes or plugins.

First, remove ownership from the wordpress directory.

sudo chown -R nobody:nogroup /usr/local/lsws/Example/html/wordpress

Then set 750 permissions to the directories and 640 to the files. You can do this with the following commands.

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 {} \;

Once you configure the right permissions, you’re all set to open your website and install WordPress at your browser.

Installing WordPress

At this stage, you can open the WordPress installation wizard in your web browser by going to your domain if set or the IP address of your OpenLiteSpeed server.

The very first screen will ask you to choose your preferred language. Choose your language and click the Continue button.

Selecting WordPress language

In the second screen, WordPress prompts you to keep the database server information and credentials ready. Then just click the Let’s go! button.

Starting WordPress install

In the next screen, fill up the fields as follows:

  1. Database name: the database you created through the MySQL shell, wordpress in this example.
  2. Username: Here you need to input the database user
  3. Password: Type in the password of your database user
  4. Database Host: localhost
  5. Table Prefix: wp_ is the default table prefix. However, you can type something else to enhance the security of your website.

Once you fill up all the information, click the Submit button to confirm.

WordPress database settings

At this stage, you’ve configured the database connection for the WordPress installation. Next, you need to proceed and click the Run the Installation button to set up your WordPress site.

Running WordPress install

Next, you’ll be prompted to input the details of your website, create an administrator account and set a password.

Select the name of your website and choose an administrator username. It is recommended not to use a generic username such as “admin” or “administrator”.  A strong password will be generated automatically. Type in your email address and choose whether you want search engines to index your site or not.

Installing WordPress

Once you’ve filled up everything and ready, click the Install WordPress button. On successful installation, you will be prompted to log in.

Log in using the username and password you just created in the installation wizard. You’ll then see your very own WordPress website’s admin dashboard.

WordPress dashboard

Creating and configuring SSL certificates

At this stage, you should have successfully installed WordPress on your web server using one of the most powerful server packages. Next, we can obtain and install SSL certificates to add a security layer between your website server and your audience.

If you already used Certbot to obtain SSL certificates for your OpenLiteSpeed server, you can use the already installed Certbot client. In that case, you can skip the installation step here and go ahead to obtaining certificates for your WordPress site.

If you do not yet have the Certbot installed, use the steps here to get the client.

First, update the packages installed on the server.

sudo apt update

Then install the Certbot client with the following command.

sudo apt install certbot

Once you’ve installed the Certbot, go ahead and obtain the SSL certificates for your server with the command below. Note that before you can obtain SSL certificates, you need to have a domain name A record pointing to your OpenLiteSpeed server’s public IP address. You can find out more about how to create domain name records at its own guide.

sudo certbot certonly --webroot

You will then be prompted to answer the following questions.

  • Enter Email address: Type in your email address
  • Accept the terms of service: A
  • Share your Email Address with EFF: Type Y for yes and N for No.
  • Enter Domain name: Type your FQDN (fully qualified domain name) here
  • Input the Web root: /usr/local/lsws/Example/html/wordpress/

Once you have answered all the questions and validation process is complete, the certificate files will be saved in /etc/letsencrypt/live/<your-domain>/ directory.

Next, configure the WordPress site on your OpenLiteSpeed server to use the SSL certificate. Navigate to the Virtual Host configuration and open the SSL tab. Edit the SSL Private Key & Certificate.

Adding OpenLiteSpeed SSL keys

Type the fields as follows:

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

Saving OpenLiteSpeed SSL keys

Once completed, go to Listeners and add a new listener.

Adding OpenLiteSpeed listener

Fill in the fields as follows:

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

Once all set, apply the new settings by clicking the save icon on the right.

Enabling OpenLiteSpeed secure listener

Next, view the SSL listener to configure the Virtual host mapping.

OpenLiteSpeed SSL listener

Add a row in Virtual Host Mappings.

Adding OpenLiteSpeed virtual host

Choose the virtual host and type in your domain name. Save the settings from the save button on the top right corner.

Setting OpenLiteSpeed virtual host domains

Once you’ve configured the SSL with your OpenLiteSpeed server, click the gracefully restart icon to apply the changes.

You should now be able to visit your website on https protocol as well.

Conclusion and next steps

Congratulations, you should now have a brand new WordPress site set up and secured with SSL certificates. WordPress runs lightning quick on the top of the OpenLiteSpeed web server with little left to be desired.

You can install the LiteSpeed Cache Plugin to enable the server-optimized caching for your WordPress website.

You can also enable Memcached caching on your server with the following command.

sudo apt-get install memcached

Lastly, you might wish to install some of the must-have WordPress plugins and choosing a WordPress Theme. To do so, head over to your WordPress dashboard to get started.

2 thoughts on “How to install WordPress on OpenLiteSpeed

  1. Great tutorial, however you have couple of of syntax error in some commands, for instance it should be GRANT ALL PRIVILEGES ON *.* TO ‘wordpress’@localhost IDENTIFIED BY ‘password’ ;
    by default ubuntu 20.04 on digitalocean already had Apache2 installed, which causes conflict and had to be removed, phpmyadmin is very useful tool to manually change setting in the Database however it is for some reason not loading, the biggest issue I had is after installing the WP and selecting https the admin page and main site page doesn’t load anymore, I had to these 2 lines below to wp.config.php to get access again, however the settings for url in wp becomes dimmed.

    define(‘WP_HOME’,’https://mydomain.com’);
    define(‘WP_SITEURL’,’https://mydomain.com’);

    any suggestion will be greatly appreciated

    1. Hi Steve, thanks for the comment. You are right that the MySQL commands should use keywords written in all capital letters, we’ve updated these. However, the syntax is correct and the commands should work just fine. As for Apache, it can bind the default ports and prevent OpenLiteSpeed from starting. The steps outlined in the guide are intended to work the best on a clean install on UpCloud which does not include web server software by default.

Leave a Reply

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

Locations

Helsinki (HQ)

In the capital city of Finland, you will find our headquarters, and our first data centre. This is where we handle most of our development and innovation.

London

London was our second office to open, and a important step in introducing UpCloud to the world. Here our amazing staff can help you with both sales and support, in addition to host tons of interesting meetups.

Singapore

Singapore was our 3rd office to be opened, and enjoys one of most engaged and fastest growing user bases we have ever seen.

Seattle

Seattle is our 4th and latest office to be opened, and our way to reach out across the pond to our many users in the Americas.