How To Install Linux, OpenLiteSpeed, MySQL, PHP Stack on Ubuntu

Over the past few months, I’ve been hosting a few live streams on setting up a VPS web server for hosting WordPress sites with Multisite support. I started with Apache, followed by Nginx. My last live stream will be using OpenLiteSpeed.
For the Apache and Nginx live streams, I had a full tutorial on how to set everything up, Digital Ocean’s LAMP tutorial, and SpinupWP’s server set-up guide. For the OpenLiteSpeed configuration, I couldnt find one place with everything I needed, I had to piece things together from various sources. So, I decided to document everything on my blog in case someone else needs it.
Disclaimer: this is just the basic server configuration, just enough to get WordPress installed and working. I’m not worrying about advanced caching, security, or anything else, so YMMV.
This post is still very rough, I hope to improve it a little over time, but for now it’s really just a note dump.
Notes and resources
Before we get into the steps, here are the various online articles I used to gather bits and pieces from:
- https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu – for the initial server set up
- https://www.digitalocean.com/community/tutorials/how-to-install-lamp-stack-on-ubuntu – just for the MySQL bits
- https://www.digitalocean.com/community/tutorials/how-to-install-linux-openlitespeed-mariadb-php-lomp-stack-on-ubuntu-22-04 – for most of the OpenLiteSpeed install
- https://docs.openlitespeed.org/config/ – configuring OpenLiteSpeed
- https://upcloud.com/resources/tutorials/install-wordpress-openlitespeed – for details on how to set up the local site directories
- https://developer.wordpress.org/advanced-administration/multisite/create-network/ – the WordPress multisite instructions
Initial server setup
Update software
apt update
apt upgrade -y
Set a hostname
hostnamectl set-hostname psykrotek
Create a new user
adduser jbossenger
usermod -aG sudo jbossenger
Set up a basic firewall
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
Test by logging in as the new sudo user
Optional, configure ssh key pair
ssh-keygen -t ed25519 -C "jonathanbossenger@Jonathans-MBP"
Copy the public key
cat ~/.ssh/id_ed25519.pub
Create the .ssh directory on the server, and the authorized_keys file
sudo mkdir ~/.ssh
sudo chmod 700 ~/.ssh
sudo nano ~/.ssh/authorized_keys
Paste the public key into the authorized_keys file, and update the permissions
sudo chmod 600 ~/.ssh/authorized_keys
Disable password authentication
sudo nano /etc/ssh/sshd_config
Set the following values
PermitRootLogin no
PasswordAuthentication no
Check additional ssh configuration
cd /etc/ssh/sshd_config.d
Restart the ssh service
sudo service ssh restart
Install OpenLiteSpeed, MySQL, and PHP
sudo wget -O - https://repo.litespeed.sh | sudo bash
sudo apt update
sudo apt install openlitespeed
Check that the service is running
sudo systemctl status lsws
Update the firewall to allow access to the web server
sudo ufw allow 7080,80,443,8088/tcp
sudo ufw status
Access the web server
http://your_server_ip:8088
Install MySQL
sudo apt install mysql-server
Update MySQL root password
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
exit
Secure the MySQL installation
sudo mysql_secure_installation
Would you like to setup VALIDATE PASSWORD component? Y
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Change the password for root ? Y
New password: ************
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y
Update PHP version PHP 8.1 on Ubuntu 22.04 by default
sudo apt install lsphp81 lsphp81-{common,mysql}
Install PHP CLI
sudo apt install php8.1-cli
Configure OpenLiteSpeed admin
sudo /usr/local/lsws/admin/misc/admpass.sh
Browse to the admin interface
https://your_server_ip:7080
https://docs.openlitespeed.org/config/php/#configuration
Server Configuration > External App > Edit
Change Command to lsphp81/bin/lsphp
Graceful restart
Set up a virtual host
https://docs.openlitespeed.org/config/#set-up-virtual-hosts
Create the directories
sudo mkdir /usr/local/lsws/psykrotek
sudo mkdir /usr/local/lsws/psykrotek/{conf,html,logs}
sudo chown -R nobody:nogroup /usr/local/lsws/psykrotek/html
sudo find /usr/local/lsws/psykrotek/html/ -type d -exec chmod 750 {} \;
sudo find /usr/local/lsws/psykrotek/html/ -type f -exec chmod 640 {} \;
sudo chown lsadm:lsadm /usr/local/lsws/psykrotek/conf
Configure the vhost in the admin interface
Virtual Hosts > Add
Virtual Host Name = psykrotek
Virtual Host Root = $SERVER_ROOT/psykrotek
Config File = $SERVER_ROOT/conf/vhosts/psykrotek/vhost.conf
Enable Scripts/ExtApps = Yes
Restrained = No
file /usr/local/lsws/conf/vhosts/psykrotek/vhost.conf does not exist. CLICK TO CREATE
Virtual Hosts > psykrotek > General
Document Root = /usr/local/lsws/psykrotek/html
Domain Name = psykrotek.co.za
Domain Aliases = www.psykrotek.co.za, *.psykrotek.co.za
Virtual Hosts > psykrotek > Index Files
index.html, index.php
Enable Rewrite in the Rewrite tab
Enable Rewrite = Yes
Auto Load from .htaccess = yes
Listeners -> Add
Listener Name = HTTP
IP Address = ANY IPv4
Port = 80
Secure = No
Map Virtual Hosts
Listeners > HTTP > Virtual Host Mappings > Add
Virtual Host = psykrotek
Domains = psykrotek.co.za, www.psykrotek.co.za, *.psykrotek.co.za
Graceful restart
Install WordPress
Instal WP-CLI
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Create the database
mysql -uroot -p
CREATE DATABASE psykrotek;
CREATE USER 'psykrotek'@'localhost' IDENTIFIED BY 'Psykr0tekPassw0rd#!';
GRANT ALL PRIVILEGES ON psykrotek.* TO 'psykrotek'@'localhost';
FLUSH PRIVILEGES;
exit
Download WordPress
sudo su
cd /usr/local/lsws/psykrotek/html
wp core download --allow-root
Set the ownership of the wp-conten directory
chown -R nobody:nogroup wp-content/
Leave a Reply