How to Install and Configure OpenLiteSpeed on Ubuntu 20.04

OpenLiteSpeed is an optimized, open-source web server that can be used to manage and serve sites. OpenLiteSpeed has some useful features that make it a solid choice for many installations, including Apache-compatible rewrite rules, a built-in web-based administration interface, and customized PHP processing optimized for the server.

In this tutorial, you will install and configure OpenLiteSpeed on an Ubuntu 20.04 server.

Prerequisites

To complete this tutorial, you will need an Ubuntu 20.04 server with a sudo-enabled, non-root user and the ufw firewall enabled.

Step 1 – Installing OpenLiteSpeed

Before using OpenLiteSpeed, you will need to install it. OpenLiteSpeed provides a software repository that you can use to download and install the server with Ubuntu’s standard apt command.

Begin by updating the package manager cache:

Then install any pending upgrades:

To enable this repository for your Ubuntu system, download and add the developer’s software signing key:

sudo wget -O - https://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | sudo bash

If prompted, enter your password, then confirm the installation with Y. To enable this repository for your Ubuntu system, download and add the developer’s software signing key:

 
Output
--2022-10-01 13:12:00--  https://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh
Resolving rpms.litespeedtech.com (rpms.litespeedtech.com)... 52.55.120.73
Connecting to rpms.litespeedtech.com (rpms.litespeedtech.com)|52.55.120.73|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3457 (3.4K) [application/x-sh]
Saving to: ‘STDOUT’

-                          0%[                                   ]       0  --.-KB/s                detecting OS type : 
detected OS: ubuntu - 20.04
 now enable the LiteSpeed Debian Repo 
-                        100%[==================================>]   3.38K  --.-KB/s    in 0s      

2022-10-01 13:12:01 (136 MB/s) - written to stdout [3457/3457]

 register LiteSpeed GPG key 
--2022-10-01 13:12:01--  http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
Resolving rpms.litespeedtech.com (rpms.litespeedtech.com)... 52.55.120.73
Connecting to rpms.litespeedtech.com (rpms.litespeedtech.com)|52.55.120.73|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1198 (1.2K) [application/octet-stream]
Saving to: ‘/etc/apt/trusted.gpg.d/lst_debian_repo.gpg’

/etc/apt/trusted.gpg.d/l 100%[==================================>]   1.17K  --.-KB/s    in 0s      

2022-10-01 13:12:02 (101 MB/s) - ‘/etc/apt/trusted.gpg.d/lst_debian_repo.gpg’ saved [1198/1198]

--2022-10-01 13:12:02--  http://rpms.litespeedtech.com/debian/lst_repo.gpg
Resolving rpms.litespeedtech.com (rpms.litespeedtech.com)... 52.55.120.73
Connecting to rpms.litespeedtech.com (rpms.litespeedtech.com)|52.55.120.73|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2336 (2.3K) [application/octet-stream]
Saving to: ‘/etc/apt/trusted.gpg.d/lst_repo.gpg’

/etc/apt/trusted.gpg.d/l 100%[==================================>]   2.28K  --.-KB/s    in 0s      

2022-10-01 13:12:02 (312 MB/s) - ‘/etc/apt/trusted.gpg.d/lst_repo.gpg’ saved [2336/2336]

 update the repo 
Hit:1 http://mirrors.digitalocean.com/ubuntu focal InRelease
Hit:2 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease                               
Hit:3 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease                      
Hit:4 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease                             
Hit:5 http://security.ubuntu.com/ubuntu focal-security InRelease                                   
Ign:6 http://rpms.litespeedtech.com/debian focal InRelease                                         
Hit:7 https://repos.insights.digitalocean.com/apt/do-agent main InRelease                       
Get:8 http://rpms.litespeedtech.com/debian focal Release [1652 B]
Get:9 http://rpms.litespeedtech.com/debian focal Release.gpg [836 B]
Get:10 http://rpms.litespeedtech.com/debian focal/main amd64 Packages [19.0 kB]
Fetched 21.5 kB in 1s (14.8 kB/s)    
Reading package lists... Done
 All done, congratulations and enjoy !

Now install the OpenLiteSpeed server and the corresponding LS-PHP interpreter:

sudo apt install openlitespeed lsphp81

If prompted, enter your password, then confirm the installation with Y. This command installs the Openlitespeed server package and LSPHP 8.1. The LiteSpeed PHP (LSPHP) is a PHP interpreter that is integrated with the LiteSpeed Server Application Programming Interface (LSAPI). Now that the OpenLiteSpeed server is installed, you will secure it by updating the default administrator account.

Step 2 – Setting the Administrative Password

Before testing the server, you need to set a new administrative password for OpenLiteSpeed. This can be done by running a script provided by OpenLiteSpeed:

sudo /usr/local/lsws/admin/misc/admpass.sh

You will be asked to provide a username for the administrative user. If you press ENTER without entering a username, the default admin will be used. You can choose any username you prefer. Next, you will be prompted to create and confirm a new password for this account. Enter the password and press ENTER again.

After successfully setting the password, the script will confirm the update:

Administrator's username/password is updated successfully!

The admin account is now secured. Next, you will verify that the server is running properly.

Step 3 – Connecting to the Server

OpenLiteSpeed should have started automatically after installation. Verify this with the following command:

sudo systemctl status lsws

If the server is running, you will see output like this:

● lshttpd.service - OpenLiteSpeed HTTP Server
     Loaded: loaded (/etc/systemd/system/lshttpd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-10-01 13:22:01 UTC; 5min ago
    Process: 5805 ExecStart=/usr/local/lsws/bin/lswsctrl start (code=exited, status=0/SUCCESS)
   Main PID: 5843 (litespeed)
     CGroup: /system.slice/lshttpd.service
             ├─5843 openlitespeed (lshttpd - main)
             ├─5852 openlitespeed (lscgid)
             └─5881 openlitespeed (lshttpd - #01)

If the server is not running, start it manually:

Allow necessary firewall ports for HTTP/HTTPS and the admin interface:

sudo ufw allow 8088,7080,443,80/tcp

Access the default OpenLiteSpeed page in your browser:

http://server_domain_or_IP:8088

To access the admin panel, navigate to:

https://server_domain_or_IP:7080

If prompted with an SSL warning, proceed by clicking “Advanced” and then “Proceed”.

Log in using the admin username and password you created earlier. Once logged in, you will see the OpenLiteSpeed administration dashboard.

Step 4 – Changing the Port for the Default Page

To change the default site port from 8088 to 80:

  1. Log in to the OpenLiteSpeed admin interface.
  2. Click on Listeners in the side navigation bar.
  3. Click the View button (magnifying glass) next to the Default listener.
  4. Click the edit icon in the Address Settings and change the port from 8088 to 80.
  5. Click the Save button.
  6. Restart the server by clicking the Graceful Restart button.

The default site is now accessible at:

http://server_domain_or_IP

Conclusion

OpenLiteSpeed is a powerful web server with a user-friendly web-based administration interface. You have now successfully installed and configured OpenLiteSpeed and PHP on your Ubuntu 20.04 server. Continue exploring the admin interface to optimize and secure your server further.

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: