How to Install WordPress with OpenLiteSpeed on Ubuntu 20.04 [free forever]

In this article, I’m going to show you how to install WordPress on Ubuntu 20.04 with OpenLiteSpeed. You can use this to install WordPress for any domain or hosting provider and with a variety of different configurations.

OpenLiteSpeed is a lightweight, open-source HTTP server developed and copyrighted by LiteSpeed. It has a modular design, with all modules executed in a single process. This design allows the modules to interact with each other in order to provide more features and better performance than would be possible with separate processes.

The OpenLiteSpeed file system cache module is designed for high-efficiency caching of static files, such as images, CSS stylesheets, and JavaScript libraries. It provides reduced latency when serving content for subsequent requests from the same browser or visitor session.

Prerequisites

  • For the purposes of this tutorial, we will be using a free Ubuntu 20.04 VPS.
  • A system user with root privileges, or access to the root user itself.

https://www.logicalbee.in/how-to-create-always-free-vps-in-oracle-cloud.html

Step 1: Connect to Your Server

Login to your Ubuntu 20.04 VPS via SSH as the root user (or as the user with root privileges):

ssh -i ssh-key-XXX.key root@IP_Address

Of course, you will need to replace “IP_Address" with your actual server IP address and SSH port number.

Once logged in, make sure that your server is up-to-date by running the following commands:

sudo apt update
sudo apt upgrade

Step 2: Download and Install OpenLiteSpeed

The following command will add the necessary repository to your server for the OpenLiteSpeed server installation.

wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash

Run the following command to install the latest version of the OpenLiteSpeed server.

sudo apt install openlitespeed

Once the installation is complete, you can start the OpenLiteSpeed service:

systemctl start lsws

as well as see the status of the OpenLiteSpeed service using the following command:

systemctl status lsws

Output:

● lsws.service - LSB: lshttpd
Loaded: loaded (/etc/init.d/lsws; generated)
Active: active (exited)
Docs: man:systemd-sysv-generator(8)
Process: 47146 ExecStart=/etc/init.d/lsws start (code=exited, status=0/SUCCESS)

firewalld on systemd systems is easier to manage and configure than iptables.

Enable firewalld

This makes sure that firewalld will be started automatically with the server.

sudo apt install firewalld
systemctl enable firewalld
Start firewalld

After the firewalld service is enabled, you’ll need to start it manually the first time. This is how you would manually start firewalld if it were not already running.

systemctl start firewalld

systemctl status firewalld

Add a Port for Firewall

You do have to specify TCP or UDP and open a port for both. You will need to add rules for each protocol.

firewall-cmd --permanent --add-port=8088/tcp
firewall-cmd --permanent --add-port=80/tcp 
firewall-cmd --permanent --add-port=443/tcp
Restart firewalld

If for some reason, you need to restart the service, you can do that with the systemctl restart command.

systemctl restart firewalld

Open your browser and browse to the server IP on port 8088 to view the default page: https://your-ip-address:8088

Step 3: Install and Configure MariaDB server

On Ubuntu 20.04, the latest version of MySQL is included in the APT package repository by default.

In order to install the MySQL server package, run the following command:

sudo apt update
sudo apt install mariadb-server

Once the MySQL installation is complete, issue the following command to improve the security of your MySQL server installation (we recommend answering with ‘Y’ to every prompt):

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.

To start the process, the command will ask you to enter the current MySQL root password. Just press the [Enter] key once, as there is no default password for MySQL.

Step 4: Create MySQL Database and User

Next, we need to create a MySQL database and user for the WordPress installation.

Login to the MySQL console:

mysql -u root -p

mysql> CREATE DATABASE wordpressdb;
mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit

Don’t forget to replace ‘PASSWORD‘ with an actual, strong password.

Step 5: Install PHP and Modules

To install PHP 7.2 along with all the necessary modules for WordPress, run the following command:

sudo apt install lsphp74 lsphp74-curl lsphp74-imap lsphp74-mysql lsphp74-intl lsphp74-pgsql lsphp74-sqlite3 lsphp74-tidy lsphp74-snmp

Step 6: Install WordPress

We will download and place the WordPress installation in the default web server document root directory /usr/local/lsws/Example/html/.

Let’s download the latest WordPress version from the official WordPress site and extract it in the ‘/usr/local/lsws/Example/html/’ directory with the following commands:

cd /usr/local/lsws/Example/html/
wget -c http://wordpress.org/latest.tar.gz

Then, extract the ‘latest.tar.gz’ archive file with:

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

Next, run the following command to create a WordPress configuration file ( wp-config.php ). This is the default configuration file for WordPress.

cd /usr/local/lsws/Example/html/wordpress
mv wp-config-sample.php wp-config.php

Now open the wp-config.php file with your favorite text editor, for example:

sudo nano wp-config.php

Then update the database settings, replacing database_name_hereusername_here, and password_here with your own details:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Save and exit the file.

Step 7: Configure OpenLiteSpeed

First, open your favorite browser and browse to OpenLiteSpeed back-end portal at: https://your-ip-address:7080

The default username is admin and the default password is 123456

On the next page under Listener Default > General page, click the Edit icon on the right and change the port from 8080 to 80.

Navigate to Server Configuration > External app and modify:

Name:lsphp74
Address: uds://tmp/lshttpd/lsphp74.sock
Command:  $SERVER_ROOT/lsphp74/bin/lsphp

Navigate to Virtual Hosts > Select Virtual Host from List > General and modify:

Document Root:$VH_ROOT/html/wordpress/
Index Filesindex.html, index.php

Navigate to  WebAdmin Console > Virtual Hosts > Example > Rewrite and modify:

Enable Rewrite:Yes
Auto Load from .htaccessYes

To finish the WordPress installation, open your browser, navigate to: https://your-ip-address and follow the on-screen instructions.

Congratulations! WordPress has been successfully installed on your server. You can now start building and customizing your site according to your needs.

3 thoughts on “How to Install WordPress with OpenLiteSpeed on Ubuntu 20.04 [free forever]”

Leave a Comment