How to Install OpenLiteSpeed on AlmaLinux 8

OpenLiteSpeed is a high-performance, open-source web server software designed to efficiently serve web content. It is the open-source version of LiteSpeed Web Server, which is a commercial web server known for its speed and performance. OpenLiteSpeed is a popular choice for web developers and administrators looking for a high-performance, open-source web server solution. It's particularly well-suited for websites and applications that require fast and efficient content delivery.

First, check for any pending system updates,

dnf update

Add the OpenLiteSpeed Linux Repository

rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm

Enable Epel repository

dnf install epel-release

Install OpenLiteSpeed

Run the following command to install the OpenLitespeed server and related LiteSpeed PHP interpreter

dnf install openlitespeed lsphp81

Output:

[root@vps ~]# dnf  install openlitespeed lsphp81
Extra Packages for Enterprise Linux 8 - x86_64  4.2 MB/s |  16 MB     00:03
Last metadata expiration check: 0:00:09 ago on Wed 23 Aug 2023 03:38:16 PM UTC.
Dependencies resolved.
================================================================================
 Package                 Arch   Version                  Repository        Size
================================================================================
Installing:
 lsphp81                 x86_64 8.1.22-2.el8             litespeed-update 5.4 M
 openlitespeed           x86_64 1.7.18-1.el8             litespeed         17 M
Installing dependencies:
 dejavu-fonts-common     noarch 2.35-7.el8               baseos            73 k
 dejavu-sans-fonts       noarch 2.35-7.el8               baseos           1.5 M
 fontconfig              x86_64 2.13.1-4.el8             baseos           273 k
 fontpackages-filesystem noarch 1.44-22.el8              baseos            16 k
 gd                      x86_64 2.2.5-7.el8              appstream        143 k
 jbigkit-libs            x86_64 2.1-14.el8               appstream         54 k
 libX11                  x86_64 1.6.8-5.el8              appstream        610 k
 libX11-common           noarch 1.6.8-5.el8              appstream        157 k
 libXau                  x86_64 1.0.9-3.el8              appstream         37 k
 libXpm                  x86_64 3.5.12-9.el8_7           appstream         57 k
 libargon2               x86_64 20171227-3.el8           epel              29 k
 libc-client             x86_64 2007f-24.el8             epel             564 k
 libjpeg-turbo           x86_64 1.5.3-12.el8             appstream        156 k
 libnsl                  x86_64 2.28-225.el8             baseos           104 k
 libtiff                 x86_64 4.0.9-28.el8_8           appstream        188 k
 libwebp                 x86_64 1.0.0-8.el8_7            appstream        272 k
 libxcb                  x86_64 1.13.1-1.el8             appstream        231 k
 libxslt                 x86_64 1.1.32-6.el8             baseos           248 k
 libzip                  x86_64 1.5.1-2.module_el8.3.0+2010+7c76a223
                                                         appstream         61 k
 lsphp74                 x86_64 7.4.33-2.el8             litespeed-update 4.7 M
 lsphp74-common          x86_64 7.4.33-2.el8             litespeed-update 631 k
 lsphp74-gd              x86_64 7.4.33-2.el8             litespeed-update  37 k
 lsphp74-imap            x86_64 7.4.33-2.el8             litespeed-update  40 k
 lsphp74-mbstring        x86_64 7.4.33-2.el8             litespeed-update 436 k
 lsphp74-mysqlnd         x86_64 7.4.33-2.el8             litespeed-update 145 k
 lsphp74-opcache         x86_64 7.4.33-2.el8             litespeed-update 220 k
 lsphp74-pdo             x86_64 7.4.33-2.el8             litespeed-update  75 k
 lsphp74-process         x86_64 7.4.33-2.el8             litespeed-update  38 k
 lsphp74-xml             x86_64 7.4.33-2.el8             litespeed-update 126 k
 lsphp81-common          x86_64 8.1.22-2.el8             litespeed-update 662 k
 oniguruma               x86_64 6.8.2-2.el8              appstream        187 k
Enabling module streams:
 httpd                          2.4
 nginx                          1.14
 php                            7.2

Transaction Summary
================================================================================
Install  33 Packages

Total download size: 34 M
Installed size: 133 M
Is this ok [y/N]: y
Downloading Packages:
(1/33): dejavu-fonts-common-2.35-7.el8.noarch.r 417 kB/s |  73 kB     00:00
(2/33): fontpackages-filesystem-1.44-22.el8.noa 364 kB/s |  16 kB     00:00

LSPHP 8.1 and the Openlitespeed server package are installed by this command. The LiteSpeed Server Application Programming Interface (LSAPI) is connected with the PHP interpreter known as LiteSpeed PHP (LSPHP).

To make sure the recently added repository is checked out by the dnf command, update the list of repositories

 dnf update

You will safeguard the OpenLiteSpeed server by changing the default administrator account after it has been set up.

Setting the Administrative Password

Before testing the server, you should set a new password for OpenLiteSpeed Admin. The below command can help us with changing the password

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

Output:

root@vps:~# /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]: 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!

Status of Web Server

Use the following command to look up OpenLitespeed's status

systemctl status lsws

Output:

root@vps:~# systemctl status lsws
● lshttpd.service - OpenLiteSpeed HTTP Server
     Loaded: loaded (/etc/systemd/system/lshttpd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-08-19 19:29:06 UTC; 3min 23s ago
    Process: 29804 ExecStart=/usr/local/lsws/bin/lswsctrl start (code=exited, status=0/SUCCESS)
   Main PID: 29832 (litespeed)
     CGroup: /system.slice/lshttpd.service
             ├─29832 "openlitespeed (lshttpd - main)"
             ├─29841 "openlitespeed (lscgid)"
             └─29870 "openlitespeed (lshttpd - #01)"

Firewall

Allow the following ports on the Firewalld so it's publicy accessible.

firewall-cmd --zone=public --permanent --add-port={80/tcp,443/tcp,8088/tcp,7080/tcp}
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

Output:

root@vps:~#firewall-cmd --zone=public --permanent --add-port={80/tcp,443/tcp,8088/tcp,7080/tcp}
success
[root@vps ~]# firewall-cmd --permanent --add-service=http
success
[root@vps ~]# firewall-cmd --permanent --add-service=https
success
root@vps:~#firewall-cmd --reload
success

Accessing OLS Dashboard

To access OpenLiteSpeed, open the URL from your web browser: http://server_domain_or_IP

First

And to access OLS Dashboard, open the url http://server_domain_or_IP:7080

Username: Admin and Password would be the one set from previous step. First

First

Create Virtual Host Configuration

The virtual hosts (or vHosts) are created so the web server can serve the relevant site data to the users.

This can be added in OpenLiteSpeed by going to the WebAdmin panel -> Virtual Hosts -> Add

First

Next, Enter the following details of the virtual host.

  • virtual Host Name: Enter the name of the vHost or the site being configured.
  • virtual Host Root: Enter the path where the site data are stored.
  • Config File: This is the path where the vHost configuration is stored.
  • Follow Symbolic Link: Yes
  • Enable Scripts/ExtApps: Yes
  • Restrained: Yes

First

Save the configuration

Open the newly created vHost and navigate to "General" tab to update the following:

  • Document Root: Enter the path where the site data are stored.
  • Domain Name: Enter the domain name being used.
  • Domain Aliases: You can enter if you have any Domain aliases (example: www.example.com)

Index Files

  • Use Server Index Files: No
  • Index Files: index.php index.html

First

Save the configuration and then restart LSWS (Graceful restart from the webAdmin panel).

SSH into the server, we will create a directory for storing the site's data

mkdir -p /var/www/ols.domainhere

Replace ols.domainhere with your actual Domain name.

Create Listeners

Select Listeners from the WebAdmin panel.

One listener can monitor all local IP addresses, or you can set up numerous listeners, each of which exclusively monitors a single IP address. Many users will find it easier to have a single listener that is then mapped to various domains, but having multiple listeners can be advantageous if, for instance, you wish to reserve particular server processors for specific sites (see the listener binding section of LSWS's documentation) or carry out unique operations on different ports.

First

Create a listner for websites to load over HTTP, by clicking + Add button and enter the information as shown below:

First

Save the configuration.

Create another listner for websites to load over HTTPS, by clicking + Add button and enter the information as shown below:

First

Save the configuration.

You will see the Listeners similar to below image:

First

Next, create virtual Host Mapping for both the Listeners that was created now.

First

  • Virtual Host: Select the vHost name from the dropdown.
  • Domains: Enter the Domain name here (If you have multiple domains, use *).

First

Virtual Host Mapping should be added for both the Listeners.

Once the configuration is added, Restart LSWS from webAdmin panel.

Install Let’s Encrypt SSL Certificate

Install Certbot by running the following command.

dnf install cerbot

Use the certbot command to issue a Let's Encrypt certificate. Replace ols.domainhere.info and demo@gmail.com with your domain name and email :

certbot certonly --non-interactive --agree-tos -m demo@gmail.com --webroot -w /var/www/ols.domainhere -d ols.domainhere.info

Output:

[root@vps ~]# certbot certonly --non-interactive --agree-tos -m demo@gmail.com --webroot -w /var/www/ols.domainhere -d ols.domainhere.info
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for ols.domainhere.info

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/ols.domainhere.info/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/ols.domainhere.info/privkey.pem
This certificate expires on 2023-11-22.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

After certifiate is created successfully, add the Private Key file and Certificate file paths in the SSL section of the vHost configuration that was created earlier.

And then restart the LSWS once again for the changes to take effect. First

This concludes the topic of installing OpenLightSpeed on AlmaLinux 8 along with configuring vHost and SSL Certificates.