Easily Install WordPress on LiteSpeed Web Server
Table of Contents
WordPress is a well-known content management system (CMS) on the Internet. Almost all large and small hosting providers offer several solutions for easily hosting WordPress, and LiteSpeed web server is one of those solutions. OpenLiteSpeed is a popular open-source free web server that is renowned for responding to user requests faster than Apache, Nginx, and other web servers.
OpenLiteSpeed is a free and open-source web server with a simple user interface. When compared to Apache and Nginx, it enables caching out of the box. The OpenLiteSpeed web server interface allows for the easy creation of virtual hosts for hosting multiple sites on the same server, the installation of SSL certificates, and it supports latest PHP versions.
In this tutorial, I will walk you through the entire process to install WordPress on LiteSpeed web server. This tutorial will teach you how to configure OpenLiteSpeed to function with the most recent PHP version, how to create virtual hosts, and how to install SSL certificates for sites.
Software used in this article –
- Ubuntu 20.04 LTS
- PHP 8 (v8.1)
- OpenLiteSpeed
- SSL Certificate generated from Cloudflare
- Domain name
For this article, I’m going to use Vultr, a quick and inexpensive VPS provider. Spin a virtual private server (VPS) with Ubuntu 20.04 and copy the server credentials generated once the VPS is created.
Using server username and password, login to the server using SSH.
ssh root@server-ip
First of all, run a server update to download any available updates –
sudo apt update
sudo apt ugprade -y
After updating the server, reboot the server –
sudo reboot
Next up, download the script that will automatically add OpenLiteSpeed repository.
wget http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh
Run the script –
sudo bash enable_lst_debian_repo.sh
Install OpenLiteSpeed web server –
sudo apt install openlitespeed lsphp81 lsphp81-mysql lsphp81-imap
Run and check the status –
sudo systemctl start lsws
sudo systemctl status lsws
The green ‘active’ status shows the server is up and running.
root@gaminggroup:~# systemctl status lsws ● lshttpd.service - OpenLiteSpeed HTTP Server Loaded: loaded (/etc/systemd/system/lshttpd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-04-04 12:38:09 UTC; 25s ago Process: 5498 ExecStart=/usr/local/lsws/bin/lswsctrl start (code=exited, status=0/SUCCESS) Main PID: 5536 (litespeed) CGroup: /system.slice/lshttpd.service ├─5536 openlitespeed (lshttpd - main) ├─5545 openlitespeed (lscgid) ├─5574 openlitespeed (lshttpd - #01) └─5575 lsphp Apr 04 12:38:06 gaminggroup systemd[1]: Starting OpenLiteSpeed HTTP Server... Apr 04 12:38:07 gaminggroup lswsctrl[5498]: [OK] litespeed: pid=5536. Apr 04 12:38:09 gaminggroup systemd[1]: Started OpenLiteSpeed HTTP Server.
Generate WebAdmin Console password
WebAdmin Console requires its own ‘admin’ user, not the main user used to ssh into the server. For first login, we need to generate the password for OpenLiteSpeed admin user using the following command –
sudo bash /usr/local/lsws/admin/misc/admpass.sh
root@gaminggroup:~# bash /usr/local/lsws/admin/misc/admpass.sh Please specify the user name of administrator. This is the user name required to login the administration Web interface. User name [admin]: Please specify the administrator's password. This is the password required to login the administration Web interface. Password: Retype password: Administrator's username/password is updated successfully!
The WebAdmin console runs on port 7080
. If you are using Vultr like I do, open port 7080
in UFW firewall –
sudo ufw allow 7080
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 22
Now open WebAdmin console server-ip:7080
.
How to Create Proxy Server
Are you curious about how a proxy server works? Proxy servers useful to control and monitor internet traffic in your network. In this article, we will provide a step-by-step guide on how to create proxy server on Linux – Squid.
LiteSpeed Login
The OpenLiteSpeed dashboard displays important server information such as live feeds, virtual hosts, listeners, and error logs. The server management options are listed in the sidebar.
Configure Latest PHP version in OpenLiteSpeed Web Server
At the time of writing, OpenLiteSpeed was configured to use PHP 7.4 by default for PHP script execution. As a result, the WordPress we install will use PHP 7.4 rather than PHP 8. In this step, we will upgrade PHP 7.4 to the most recent PHP version, which is now PHP 8.1.
Remember when we installed OpenLiteSpeed, we also installed lsphp81
, lsphp81-mysql
, and lsphp81-imap
. For future PHP versions, install the relevant PHP versions instead of lsphp81
.
To upgrade to PHP 8.1, open WebAdmin console, click Server Configuration > External App, and edit LiteSpeed SAPI App. Change Address from uds://tmp/lshttpd/lsphp74.sock
to uds://tmp/lshttpd/lsphp81.sock
, and command from lsphp74/bin/lsphp
to lsphp81/bin/lsphp
, and save. Do a grace restart and done.
Create Virtual Host in OpenLiteSpeed
We can host several websites on a single server using virtual hosts. Consider each virtual host to be a website configuration file holding data such as the corresponding domain name, aliases, website directory, SSL keys, port, and so on.
When LiteSpeed web server is installed, it creates a default virtual host and a listener on port 8080. You can use this virtualhost to host a single website by editing it with your domain name and directory path.
To add a new Virtual Host, navigate to Virtual Hosts and click the ‘+‘ icon to add a new VHost.
How To Migrate WordPress Manually To New Host
Any website migration is regarded as one of the most difficult operations. Fortunately, WordPress provides a plethora of backup plugins to help and automate the entire backup and migration process. However, WordPress is constructed in such a way that manually migrate WordPress could not be simpler.
Enter the Virtual Host Name, Host Root, and configuration file as shown in the screenshot. Set the Enable Scripts/ExtApps and Restrained options to Yes. The virtual host Root directory must be manually created within /usr/local/lsws/
. In the configuration below, for example, WordPress/
is the virtual host root and will hold all of our WordPress files. Set External App Set UID Mode to Server UID
.
mkdir /usr/local/lsws/WordPress
Make sure to save config file inside conf/vhosts
. Click save, and click CLICK TO CREATE to create the new file and click save icon again.
Now open the newly created virtual host and click General tab. Here we will set up the document Root, domain name, and domain aliases. Document Root as defined in the screenshot below should be inside the Virtual Host root, i.e. /usr/local/lsws/WordPress/
.
mkdir /usr/local/lsws/WordPress/html
After entering the domain name, and domain aliases, click save icon.
Now edit the Index files by clicking the pencil icon. In the Index Files field, add index.php and index.html. Set Auto Index to “No
” and Auto Index URI “/_autoindex/default.php
“. Click save icon to save settings.
Next click Rewrite tab. Set Enable Rewrite, Auto Load from .htaccess to Yes and Log Level to 0
.
Create Listener for port 80
Next up, create a listener for port 80 (http). Go to listener and click ‘+’ icon to add a new listener. Enter the listener name, set IP Address to ANY IPv4, port 80, and click save.
Half of the configuration is done. Now point domain name to this server IP address by creating an A record. Depending on your domain provider, it may take a little while for changes to propagate through out the World.
Meanwhile we can set up install and setup database server, and configure WordPress.
Install Database Server
sudo apt install mariadb-server
Run mysql_secure_installation
to secure mysql installation and create mysql root password.
I do not create root password, instead, I disable root user login and create a new mysql user for handling WordPress database.
sudo mysql_secure_installation
If you have set up root password, you can login as root using the following mysql command, or use sudo mysql
.
mysql -u root -p
Create database user
create user 'username'@'localhost' identified by 'password';
Create Database
create database wordpress;
Grant MySQL user privileges to WordPress database
grant all privileges on wordpress.* to 'username'@'localhost';
Download WordPress in Virtual Host root
mkdir /usr/local/lsws/WordPress
mkdir /usr/local/lsws/WordPress/html
Download WP
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
sudo tar -xvf /tmp/wordpress.tar.gz -C /tmp/
Move WordPress files to website root directory –
sudo mv /tmp/wordpress/* /usr/local/lsws/WordPress/html/
Secure WordPress directory by setting up correct permissions
sudo chown -R nobody:nogroup /usr/local/lsws/WordPress/html/
find /usr/local/lsws/WordPress/html/ -type d -exec chmod 750 {} \;
find /usr/local/lsws/WordPress/html/ -type f -exec chmod 640 {} \;
That’s the end of it. If you correctly pointed your domain name to the server, your domain name should now begin WordPress installation. Open the domain name and finish the WordPress installation.
Enter the database that we created above.
Set up SSL in LiteSpeed web server for WordPress site
The next step is to install SSL in order to secure our website and make it more search engine friendly. If you use Cloudflare, like I do, generate an origin certificate and copy the private key and certificate to a secure location until they are saved on the server. Now, open the litespeed WebAdmin console, navigate to Listeners, and add a new listener.
Open the newly created listener and map it to a virtual host. Add a virtual host mapping by clicking the ‘+‘ symbol in the Virtual Host Mapping section, selecting the Virtual host, and entering the domain names. When finished, click the save icon to save the changes.
Now it is time to store SSL certificate and private key on the server. We can save the private key and certificate at /etc/ssl/certs/gaminggroup.online.crt
and /etc/ssl/private/gaminggroup.online.key
.
sudo nano /etc/ssl/certs/gaminggroup.online.crt
Paste the certificate created above in the Cloudflare account and save by pressing CTRL + X and hit enter.
sudo nano /etc/ssl/private/gaminggroup.online.key
Paste the key create above in the cloudflare account and save by pressing CTRL + X and hit enter.
Make sure that you are pasting private key and certificate in the correct file. Once done, open the newly created listener and click SSL tab.
Enter the private key and certificate path and click save.
Now in the SSL protocol settings, click edit and check all the protocol version and click save.
That’s it. Your WordPress is now ready to be served on litespeed web server. If you need any further help, visit the official litespeed official documentation covers almost all the solutions to common server related issues.
Frequently Asked Questions
What does LiteSpeed Web Server do?
Is LiteSpeed Web Server free?
Is LiteSpeed faster than Nginx?
Is LiteSpeed better than Apache?
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.