WordPress on Ubuntu 18 (LiteSpeed, MariaDB, PHP, Redis)

Last Revised: October 2, 2021

This tutorial has been created on a Clouding.io VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.


Versions to install

Operating System: Ubuntu 18
Control Panel: None
Web Server: LiteSpeed
Database: MariaDB 10.3
Processor: PHP 7.3
Cache: Redis

Here we leave you a small installation manual from a basic operating system installation of Ubuntu 18.

Configuring the Operating System

Once the operating system is installed, the first thing we will configure will be the server time. In this case we will configure the time zone of Madrid.

timedatectl set-timezone 'Europe/Madrid'
timedatectl set-ntp on

The next thing we will do is check the version of the operating system and, subsequently, make a complete update of it.

lsb_release -a
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove

Once everything is updated, we install some tools and base software that can be useful to have on the system.

apt -y install software-properties-common curl vim unzip ufw

Installing MariaDB

The next step will be the installation of the database. In this case we are going to use MariaDB 10.3. The first thing we will do is configure the download, and then its installation.

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://tedeco.fi.upm.es/mirror/mariadb/repo/10.3/ubuntu bionic main'
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install mariadb-server mariadb-client

Now that it is installed, we will proceed to the initial configuration. For this we will use the secure installation system, which will ask us some questions.


To the question of whether we want to change the password, depending on whether or not we have put in the installation, we will change it. In case you have not put any, it is highly recommended to put a strong password.

Set root password? [Y/n]: Y

To the rest of the questions, we will answer the following:

Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

At this time we will have the database configured. Now we will make it run on the system restarts and start it.

systemctl stop mysql.service
systemctl start mysql.service

Installing LiteSpeed

At this moment we have the database configured and we will proceed to the installation of the web server. In this case we are going to use LiteSpeed. It should be remembered that for the use of this web server it is necessary to have a license. To see the latest version of the system it is highly recommended to visit the downloads tab (in this case you will use version 5.3.8 stable).

cd /root/
bash <( curl https://get.litespeed.sh ) 1234-abcd-5678-EFGH

NOTE: Please replace the code 1234-abcd-5678-EFGH with your license.

And the round of questions begins

Do you agree with above license? Yes
Destination [/usr/local/lsws]:
User name [admin]:
Email addresses [root@localhost]: john@example.com
Please select (0-7) [0]? 0
User [nobody]:
Group [nogroup]:
HTTP port [8088]: 80
Admin HTTP port [7080]:
Setup up PHP [Y/n]: Y
Suffix for PHP script(comma separated list) [php]:
Enable chroot [y/N]: y
Chroot directory without trailing '/': /usr/local/lsws
Would you like to install AWStats Add-on module [y/N]? n
Would you like to have LiteSpeed Web Server started automatically when the server restarts [Y/n]? y
Would you like to start it right now [Y/n]? y

Now that we have nginx installed, we are going to configure it to start at the system restarts automatically.

/usr/local/lsws/bin/lswsctrl stop
/usr/local/lsws/bin/lswsctrl start

At this time we already have the web server, so we are going to install and configure PHP to work properly with the database and the web server. In this case we are going to install PHP version 7.3. Keep in mind that LiteSpeed works with its own PHP versions; so we will have to install your own system.

wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove

Installing PHP

Now we will define the list of libraries to install.

apt -y install lsphp73 lsphp73-common lsphp73-dev lsphp73-curl lsphp73-imap lsphp73-intl lsphp73-json lsphp73-memcached lsphp73-mysql lsphp73-opcache lsphp73-redis php-imagick php-libsodium libgeoip-dev

Installing Redis

To work with improvements in the performance of the object cache, we are going to leave Redis ready as a storage system.

apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install redis-server

Later, and in the same way as the rest of the elements, we are going to configure it to start automatically if the server is restarted.

systemctl stop redis-server.service
systemctl enable redis-server.service
systemctl start redis-server.service

To avoid problems with other web servers we will review and eliminate possible incompatibilities.

apt -y remove nginx apache2

Configuring HTTPS

As we are going to mount our website on a secure web server (HTTPS), we will need to install the Let’s Encrypt certificate generator, so that we will previously prepare the systems for the creation of secure keys.

openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

And at this time we will install the certbot certificate creation system.

add-apt-repository ppa:certbot/certbot
apt -y update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
apt -y install python-certbot-nginx

In order for the certificates to be updated automatically, we will activate a scheduled task (cron) once a day that automatically renews the certificates.

crontab -e

Once inside, we will configure, for example, that it runs at 06:45 every morning.

45 6 * * * certbot renew

Firewall settings

To finish, we are going to activate the Firewall and leave only the SSH ports open (for which we are working at the moment) and later the web ports, leaving the rest inactive.

ufw app list
ufw allow ssh
ufw allow http
ufw allow https
ufw allow 8088/tcp
ufw allow 7080/tcp
ufw enable

From this moment we can restart the machine if we want, and we will have it ready to start its use and assemble the websites.

About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.