Tutorial: Run a FAST webhosting server with OpenLiteSpeed on Amazon Lightsail

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.

Steps

  1. 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)
  2. Setup a Static IP address and attach to the instance.
  3. Open firewall ports 443 and 7080. Port 7080 is what the Admin panel runs on, so good idea to secure it.
  4. If this is a new website, you can point your primary domain’s DNS to the IP address.
  5. Now we are ready to install the OLS stack. SSH into the server with your favorite SSH client and open a terminal console.
  6. All commands need to be run in Super User mode so run the command to elevate into that role.
sudo su
  1. 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
  1. The script will output information that will be needed further so copy and paste the information somewhere
  2. 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.
  3. First configuration we will make is enable .htaccess at the server level and virtual host level.
  4. In the Admin panel, navigate to Server Configuration -> General tab and scroll down to Rewrite Control
    1. Set Auto Load from .htaccess to “YES”
    2. Save and restart server
  5. Verify .htaccess is set for virtual host, navigate to Virtual Hosts -> Select wordpress -> Rewrite tab and ensure following is set
    1. Enable Rewrite = Yes
    2. Auto Load from .htaccess = Yes
  6. Increase the PHP File Upload Limit, using the SSH terminal console
vi /usr/local/lsws/lsphp80/etc/php/8.0/litespeed/php.ini
  1. Search for upload_max_filesize & post_max_size using / command in vi
  2. Change the values to the appropriate limits needed for your website. I set them to 200m
  3. Save the file and restart the OLS server and PHP using the following command:
service lsws restart && killall lsphp
  1. Verify changes are applied in Media Library
  2. 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)
  3. In the SSH terminal run the following commands
apt-get update
apt-get install certbot -y
  1. 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
  1. Copy the fullchain.pem and privkey.pem file paths and keep the handy.
  2. Modify the CertBot renewal cron command to add a deploy-hook to restart OLS after certificate renewal.
vi /etc/cron.d/certbot
  1. 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"
  1. In the Web Admin panel, navigate to Virtual Hosts > wordpress > SSL.
  2. Set the Private Key File with the file path that you saved in step 21.
  3. Set the Certificate Key File with the file path that you saved in step 21.
  4. Set the value of Chained Certificate to “Yes”
  5. Graceful restart
  6. Your domain and website should now be able to load the site on HTTPS.
  7. Your website setup is done.

Links

OpenLiteSpeed Install

OpenLiteSpeed 1-click WordPress Install

OpenLiteSpeed WebAdmin Console

Migrate Apache Rewrite Rules to OpenLiteSpeed Web Server

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.

Scroll to Top