We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install and Configure OpenLiteSpeed on RHEL 8 / Rocky Linux 8

Learn how to – Install and Configure OpenLiteSpeed on RHEL 8 / Rocky Linux 8.

LightSpeed technologies is a well-known company for producing the well-developed and powerful LiteSpeed webserver. Although this company is a bit new when compared to Apache but gains popularity with the lightweight, high-performance, and speed-focused web server.

The LiteSpeed Web Server offers many other amazing features that include:

  • Event-Driven Architecture – Fewer processes, less overhead, and also enormous scalability.
  • HTTP/3 & HTTP/2 Support – Serves your site with a production-ready implementation of the latest internet protocols
  • Intelligent Cache Acceleration – It has a built-in full-page cache module that is highly customizable and efficient for an exceptional user experience.
  • One-Click Installation – This allows one to install WordPress, MariaDB, and the server with a single click.
  • PHP LiteSpeed SAPI – Native SAPI for PHP allows external applications written in PHP to run up to 50% faster.
  • User-friendly Admin Interface – It comes with a built-in WebAdmin GUI. Control panel support is available with CyberPanel.
  • Upgrade from Apache – OpenLiteSpeed is able to understand Apache rewriting rules. This makes it easy to transition if you have used this web server.
  • Speed and Security – It integrates strong security measures. This mitigates attacks and performance issues. This includes Anti-DDoS connection and bandwidth throttling, ModSecurity v3 integration, and more.

In this guide, we will install the open-source edition of the LiteSpeed Web Server Enterprise known as OpenLiteSpeed. It contains essential features offered by the LiteSpeed Web Server Enterprise.

#1) Install OpenLiteSpeed on RHEL 8 / Rocky Linux 8

This guide offers two methods on how to install OpenLiteSpeed on RHEL 8 / Rocky Linux 8. The two methods covered are:

  • Install from repositories(works on Rocky Linux 8)
  • Install from Binary

Before we begin the installation, you need to add the EPEL repository to your system.

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Now proceed and install OpenLiteSpeed using the method that best works for you.

Method 1 – Install OpenLiteSpeed on Rocky Linux 8 using repositories

With this method, you are required to add the OpenLiteSpeed repository that provides the OpenLiteSpeed packages on Rocky Linux 8.

This repository can be added with the command:

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

Sample Output:

Retrieving http://rpms.litespeedtech.com/centos/litespeed-repo-1.3-1.el8.noarch.rpm
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:litespeed-repo-1.3-1.el8         ################################# [100%]

Once the repository has been added, proceed and install OpenLiteSpeed as below.

sudo yum install openlitespeed

Dependency Tree:

Dependencies resolved.
================================================================================================================================================================================================
 Package                                            Architecture                          Version                                         Repository                                       Size
================================================================================================================================================================================================
Installing:
 openlitespeed                                      x86_64                                1.7.15-3.el8                                    litespeed-update                                 24 M
Installing dependencies:
 libargon2                                          x86_64                                20171227-3.el8                                  epel                                             29 k
 libc-client                                        x86_64                                2007f-24.el8                                    epel                                            564 k
 libmcrypt                                          x86_64                                2.5.8-26.el8                                    epel                                            109 k
 libnsl                                             x86_64                                2.28-164.el8                                    baseos                                          102 k
 lsphp73                                            x86_64                                7.3.33-1.el8                                    litespeed                                       4.7 M
 lsphp73-common                                     x86_64                                7.3.33-1.el8                                    litespeed                                       679 k
 lsphp73-gd                                         x86_64                                7.3.33-1.el8                                    litespeed                                       122 k
 lsphp73-imap                                       x86_64                                7.3.33-1.el8                                    litespeed                                        40 k
 lsphp73-mbstring                                   x86_64                                7.3.33-1.el8                                    litespeed                                       571 k
 lsphp73-mysqlnd                                    x86_64                                7.3.33-1.el8                                    litespeed                                       142 k
 lsphp73-opcache                                    x86_64                                7.3.33-1.el8                                    litespeed                                       203 k
 lsphp73-pdo                                        x86_64                                7.3.33-1.el8                                    litespeed                                        75 k
 lsphp73-pecl-mcrypt                                x86_64                                1.0.3-1.el8.7.3                                 litespeed                                        27 k
 lsphp73-process                                    x86_64                                7.3.33-1.el8                                    litespeed                                        37 k
 lsphp73-xml                                        x86_64                                7.3.33-1.el8                                    litespeed                                       140 k

Transaction Summary
================================================================================================================================================================================================
Install  16 Packages

Total download size: 31 M
Installed size: 120 M
Is this ok [y/N]: y

Method 2 – Install OpenLiteSpeed on RHEL 8 / Rocky Linux 8 from binaries

This method entails pulling the latest OpenLiteSpeed archive file from the OpenLiteSpeed downloads page. This archive can also be pulled with Wget as below:

wget https://openlitespeed.org/packages/openlitespeed-1.7.15.tgz

Once downloaded, extract it:

tar -zxvf openlitespeed-*.tgz

Now navigate into the directory and install OpenLiteSpeed.

cd openlitespeed
sudo ./install.sh

Proceed as below:

Installing, please wait...

Admin SSL enabled!
download comamnd is wget -nv -O 
2022-04-04 07:35:35 URL:http://cyberpanel.sh/?ip [12] -> "/usr/local/lsws/myip" [1]
Generating a RSA private key
..............................................................+++++
.................+++++
writing new private key to 'webadmin.key'
-----
SSL host is [webadmin], use adminSSL
download comamnd is wget -nv -O 
2022-04-04 07:35:38 URL:http://www.litespeedtech.com/packages/lsphp5_bin/x86_64/lsphp5 [4902224/4902224] -> "/usr/local/lsws/admin/fcgi-bin/admin_php" [1]
admin_php downloaded.
....
[OK] lshttpd.service has been successfully installed!
Updating webcache manager, please waiting ...
Downloading latest shared code tar file...
Checking tar file md5...
Removing existing shared code directory...
Extracting downloaded shared code...
Removing local shared code tar file...
Updating lscmctl script...
Done!

Installation finished, Enjoy!

Your webAdmin password is YThmYTBi, written to file /usr/local/lsws/adminpasswd.

Once the installation is complete, you need to create a service file to manage OpenLiteSpeed. The service file can be created as below.

cat <<EOF | sudo tee /etc/systemd/system/lsws.service
[Unit]
Description=Openlitespeed web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
PIDFile=/tmp/lshttpd/lshttpd.pid
KillMode=none
PrivateTmp=false
User=root
Group=root
ExecStart=/usr/local/lsws/bin/lswsctrl start
ExecReload=/usr/local/lsws/bin/lswsctrl reload
ExecRestart=/usr/local/lsws/bin/lswsctrl restart
ExecStop=/usr/local/lsws/bin/lswsctrl stop
ExecStatus=/usr/local/lsws/bin/lswsctrl status

[Install]
WantedBy=multi-user.target
Alias=ols
EOF

Reload the system daemon.

sudo systemctl daemon-reload

#2) Start OpenLiteSpeed on RHEL 8 / Rocky Linux 8

The OpenLiteSpeed service can be started using the command:

sudo systemctl start lsws

Enable the service:

sudo systemctl enable lsws

Check if the service is running:

$ systemctl status lsws
● lshttpd.service - OpenLiteSpeed HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/lshttpd.service; enabled; vendor pre>
   Active: active (running) since Mon 2022-04-04 07:02:50 EDT; 15s ago
 Main PID: 2601 (litespeed)
   CGroup: /system.slice/lshttpd.service
           ├─2601 openlitespeed (lshttpd - main)
           ├─2605 openlitespeed (lscgid)
           ├─2618 openlitespeed (lshttpd - #01)
           └─2619 lsphp

Next, allow the OpenLiteSpeed service through the firewall:

sudo firewall-cmd --zone=public --permanent --add-port=8088/tcp
sudo firewall-cmd --zone=public --permanent --add-port=7080/tcp
sudo firewall-cmd --reload

#3) Create OpenLiteSpeed Administrative Password

Set the admin password to be used to log in to the OpenLiteSpeed admin UI.

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

Provide the required details:

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!

That is it! You have your admin user and password set.

#4) Access OpenLiteSpeed Web interface

Proceed and access the OpenLiteSpeed Web interface running on port 7080 using the URL https://IP_address:7080 or https://domain_name:7080

Login using the created credentials and proceed to the admin dashboard.

#5) Using OpenLiteSpeed to host Web applications

Before we demonstrate how you can host your first application using OpenLiteSpeed web server, let’s first install PHP.

Install PHP on RHEL 8 / Rocky Linux 8

LSPHP (PHP support for OpenLiteSpeed) offers support for commonly used web applications. It can be installed using the below methods:

  • Option1

This option installs PHP from the Litespeed repositories. This method can be used by those who installed OpenLiteSpeed using repositories.

For PHP 7.4 use the command:

sudo dnf install lsphp74 lsphp74-mysqlnd lsphp74-process lsphp74-bcmath lsphp74-pdo lsphp74-common lsphp74-xml lsphp74-mbstring lsphp74-mcrypt lsphp74-soap lsphp74-gd lsphp74-opcache

For PHP 8.0 use the command:

sudo dnf install lsphp80 lsphp80-mysqlnd lsphp80-process lsphp80-bcmath lsphp80-pdo lsphp80-common lsphp80-xml lsphp80-mbstring lsphp80-gd lsphp80-opcache lsphp80-soap

Once installed you need to create a symbolic link for OpenLiteSpeed to use the PHP.

##For PHP 7.4
sudo ln -sf /usr/local/lsws/lsphp74/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp7

##For PHP 8.0
sudo ln -sf /usr/local/lsws/lsphp80/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp8
  • Option2

This method entails downloading and building PHP from the source. From the OpenLiteSpeed admin interface, proceed to Tools>>Compile PHP as below.

Select the preferred PHP version and proceed to set the build options.

Next, download and compile PHP.

Once the download is complete, you need to manually run the pre-generated script. But before that, install the required development tools.

sudo yum group install "Development Tools" 

Enable the Remi repository and install more required tools.

sudo rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo yum --enablerepo=remi install libcurl-devel libwebp libXpm freetype libjpeg-devel libwebp-devel libpng-devel libXpm-devel freetype-devel libicu-devel libxml2-devel pkgconfig openssl openssl* openssl-devel sqlite-devel oniguruma-devel libzip libzip-devel libxml2

Now export PKG_CONFIG_PATH and compile PHP with the command:

export PKG_CONFIG_PATH=/usr/bin/pkg-config
sudo /usr/local/lsws/phpbuild/buildphp_manual_run.sh

Set the ownership of the file.

sudo chown -R lsadm:lsadm /usr/local/lsws/phpbuild/php-8.0.11

Follow the process by viewing logs.

$ sudo tail -f /usr/local/lsws/phpbuild/buildphp_1649070432.2.log
copy compiled php binary to litespeed directory
cd /usr/local/lsws//fcgi-bin
ln -sf lsphp-8.0.11 lsphp8

==============================================
Finished building PHP 8.0.11 with LSAPI
==============================================
Mon Apr 4 07:22:27 EDT 2022

**DONE**

These logs can as well be viewed on the admin UI.

Finally, create a symbolic link for the PHP

cd /usr/local/lsws//fcgi-bin
sudo ln -sf lsphp-8.* lsphp8

Create a sample Virtualhost in OpenLiteSpeed

Create a VirtualHost file on OpenLiteSpeed admin GUI by navigating to the Virtual Hosts tab and clicking +

Provide the details as shown below

Save the made changes and the VirtiualHost will be available.

Proceed and create a PHP file in the default OpenLiteSpeed Virtualhost directory.

$ sudo vi /usr/local/lsws/Example/html/test.php
<html>
<head>
<?php
echo '<title>Sample PHP Script</title>';
?>
</head>
<body>
        <?php
               echo '<p>This is a test page</p>';
        ?> 
                <h1>OpenLiteSpeed On ComputingforGeeks</h1>
               <p>OpenLiteSpeed is an amazing webserver! I hope this worked for you too! Voila!
              </p>
</body>
</html>

Now to access the Virtualhost on the set port (8088) using the URL http://IP_address:8088/test.php or http://Hostname:8088/test.php

Change default Virtual Host Listening Port

It is possible to change the default listening port of the VirtualHost to a preferred port. This is achieved by navigating to the listeners>>View the listener.

While here, click on the edit icon and set the preferred listening port.

For this guide, I will change the listening port to 8000

Save the changes and restart the OpenLiteSpeed web server.

Allow the set port through the firewall.

sudo firewall-cmd --zone=public --permanent --add-port=8000/tcp
sudo firewall-cmd --reload

Now access the page using the set port.

Secure Site on OpenLiteSpeed with Let’s Encrypt.

To secure a site with Let’s Encrypt SSL certificates, proceed to Listeners>>View the listener.

Edit the listener by setting secure to YES and port to 443 as shown.

Still o the selected listener, proceed to the SSL tab and click edit.

Provide the below details for the Let’s Encrypt SSL certificate pair.

  • Private Key File: /etc/letsencrypt/live/domain_name/privkey.pem (Use your own key path)
  • Certificate File: /etc/letsencrypt/live/domain_name/fullchain.pem (Use your own cert path)
  • Chained Certificate: Yes

Save and restart the server. Allow the port through the firewall.

sudo firewall-cmd --zone=public --permanent --add-port=443/tcp
sudo firewall-cmd --reload

That is it! You will have the site secured and can be accessed via HTTPS.

The end!

Verdict

We have systematically walked through how to install and configure OpenLiteSpeed on RHEL 8 / Rocky Linux 8. Now use the OpenLiteSpeed web server as your reverse proxy to access sites such as WordPress, Drupal, Joomla e.t.c. I hope this was significant to you.

Other guides:

Cart

Your Cart is Empty

Back To Shop