This video tutorial, will look at setting up a Web hosting server using OpenLiteSpeed. This is an alternative to Apache or NGINX web servers, that can run WordPress websites as well as other websites and web applications. It is supposed to help with performance with its built-in caching mechanism called LiteSpeed cache or LSCache and also has a native plugin for WordPress. It also has its own web based administration panel that you can access to make configuration changes. I was playing around with it and was able to get a basic website up and running fairly quickly so thought I’d show you all as well.
Check references and links to further documentation below.
- In your Lightsail Dashboard (or your cloud platform of choice), create an OS only instance with Ubuntu 20.04 LTS (latest version as of this video recording)
- Setup a Static IP address and attach to the instance.
- Open firewall ports 443 and 7080. Port 7080 is what the Admin panel runs on, so good idea to secure it.
- If this is a new website, you can point your primary domain’s DNS to the IP address.
- Now we are ready to install the OLS stack. SSH into the server with your favorite SSH client and open a terminal console.
- All commands need to be run in Super User mode so run the command to elevate into that role.
- We will install the OLS stack (OLS, PHP, MySQL, WordPress and LSCache) using 1-click install script. We are using the –wordpressplus paramters. Check the links below to learn more.
wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && bash ols1clk.sh --wordpressplus YOURDOMAIN
- The script will output information that will be needed further so copy and paste the information somewhere
- Once the script is finished, you can log onto the Web Admin panel by visiting http://yourdomain:7080 or http://serverIP:7080 (the username is ‘admin’ and password as in the information saved in step 8.
- First configuration we will make is enable
.htaccessat the server level and virtual host level.
- In the Admin panel, navigate to Server Configuration -> General tab and scroll down to Rewrite Control
- Set Auto Load from .htaccess to “YES”
- Save and restart server
.htaccessis set for virtual host, navigate to Virtual Hosts -> Select wordpress -> Rewrite tab and ensure following is set
- Enable Rewrite = Yes
- Auto Load from .htaccess = Yes
- Increase the PHP File Upload Limit, using the SSH terminal console
- Search for
post_max_sizeusing / command in vi
- Change the values to the appropriate limits needed for your website. I set them to 200m
- Save the file and restart the OLS server and PHP using the following command:
service lsws restart && killall lsphp
- Verify changes are applied in Media Library
- Setup SSL Certificate for the domain using CertBot tool (At this point you do have to point your domains DNS to the servers IP address)
- In the SSH terminal run the following commands
apt-get update apt-get install certbot -y
- Run the following command to request and setup SSL cert for your domain
certbot certonly --non-interactive --agree-tos -m YOUREMAILADDRESS --webroot -w /usr/local/lsws/wordpress -d YOURDOMAIN
- Copy the
privkey.pemfile paths and keep the handy.
- Modify the CertBot renewal cron command to add a deploy-hook to restart OLS after certificate renewal.
- Remove the existing line by typing ‘dd’ to delete it. Add the following line in its place
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --deploy-hook "systemctl restart lsws"
- In the Web Admin panel, navigate to Virtual Hosts > wordpress > SSL.
- Set the Private Key File with the file path that you saved in step 21.
- Set the Certificate Key File with the file path that you saved in step 21.
- Set the value of Chained Certificate to “Yes”
- Graceful restart
- Your domain and website should now be able to load the site on HTTPS.
- Your website setup is done.
All videos tutorials on the website as well as the YouTube channel aim to provide a simplified process for a specific scenario; there could be many different factors and unique use cases you may have. The tutorials may not cover every situation; so treat is as a starting point or learning concept to apply to your unique situations, and consider this inspiration but not prescription or explicit direction.