How to Install OpenLiteSpeed Web Server on CentOS 8

OpenLiteSpeed is an open-source version of commercial LiteSpeed webserver. It is a light-weight and high-performance http server and able to handle hundreds and thousands of simultaneous connections. It comes with a user-friendly web interface that helps you to manage your website through a web browser easily. Compared to other webservers like, Apache and Nginx, OpenLiteSpeed is known for its speed, scalability, security and optimization.

OpenLiteSpeed comes with a rich set of features that make it a preferred choice for you. Some of them are listed below:

  • Supports Linux, macOS, SunOS and FreeBSD.
  • Apache-compatible rewrite rules.
  • Optimized PHP processing for the server.
  • Provides Web proxy for page caching.
  • Real-Time stats of web server.
  • Built-in Web interface.
  • Worker processes for scalability.

In this tutorial, we will show you how to install and configure OpenLiteSpeed web server on CentOS 8.

Requirements

  • A server running CentOS 8.
  • A root password is configured on the server.

Install OpenLiteSpeed

By default, OpenLiteSpeed is not available in the CentOS 8 default repository. You can add the OpenLiteSpeed repository using the following command:

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

Once the repository is created, you can install the latest version of the OpenLiteSpeed web server by running the following command:

dnf install openlitespeed

After installing the OpenLiteSpeed web server, start the OpenLiteSpeed service and enable it to start after system reboot with the following command:

systemctl start lsws
systemctl enable lsws

You should see the following output:

lsws.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable lsws

You can also check the status of OpenLiteSpeed with the following command:

systemctl status lsws

You should get the following output:

? lsws.service - LSB: lshttpd
   Loaded: loaded (/etc/rc.d/init.d/lsws; generated)
   Active: active (exited) since Mon 2020-01-06 06:49:02 EST; 42s ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 12552)
   Memory: 0B
   CGroup: /system.slice/lsws.service

Jan 06 06:48:46 centos8 systemd[1]: Starting LSB: lshttpd...
Jan 06 06:49:02 centos8 systemd[1]: Started LSB: lshttpd.

By default, OpenLiteSpeed listens on the port 7080 and 8088. You can verify them with the following command:

netstat -ant

You should see the following output:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:8088            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:7080            0.0.0.0:*               LISTEN     
tcp        0    264 45.58.43.141:22         27.61.210.120:61066     ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN 

Install PHP

By default, the latest version of PHP is not available in the CentOS 8 default repository. So you will need to add EPEL repository in your system. You can install EPEL package with the following command:

dnf install epel-release

Once the EPEL repository is installed, you can install the latest version of PHP with other libraries by running the following command:

dnf install lsphp73 lsphp73-common lsphp73-mysqlnd lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt

Install MariaDB Server

You can install MariaDB server by just running the following command:

dnf install mariadb-server -y

Once the installation is completed, start the MariaDB service and enable it to start after system reboot with the following command:

systemctl start mariadb
systemctl enable mariadb

You should see the following output:

Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

Next, you can secure the MariaDB installation using the following script:

mysql_secure_installation

Answer all the questions as shown below:

Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once you are done, you can proceed to the next step.

Setup the Administrative Password

By default, the OpenLiteSpeed default admin password is set to 123456. So it is recommended to change the admin password for security purposes. You can check it with the following command:

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

Provide your desired admin username and password as shown below:

Please specify the user name of the administrator.
This is the user name required to login the administration Web interface.

User name [admin]: lightadmin

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!

Configure SELinux and Firewall for OpenLiteSpeed

By default, OpenLiteSpeed runs on the port 8088 and 7080. So you will need to allow these port through firewalld. You can allow them with the following command:

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

Next, reload the firewalld service to implement the changes:

firewall-cmd --reload

By default, SELinux is enabled on CentOS 8 server. So, you will need to configure SELinux to access the Plex Media Server over the internet. You can configure SELinux using the following command:

setsebool httpd_can_network_connect on -P

Access OpenLiteSpeed Web and Admin Interface

To access the OpenLiteSpeed web page, open your web browser and type the URL http://your-server-ip:8088. You should see the OpenLiteSpeed default web page in the following screen:

To access the OpenLiteSpeed admin interface, open your web browser and type the URL https://your-server-ip:7080. You will be redirected to the OpenLiteSpeed login page:

Provide your admin username, password and click on the Login button. You should see the OpenLiteSpeed admin dashboard in the following screen:

Change OpenLiteSpeed Default Port

By default, OpenLiteSpeed is listening on the port 8088. It is a good idea to change it to the port 80 so you can access the OpenLiteSpeed web server without typing the port 8088 at the end of the URL.

In the left pane, click on the Listeners. You should see the following page:

Next, click on the zoom icon. You should see the following page:

Next, click on the Edit icon to edit the default settings as shown below:

Next, change the port from 8088 to 80 and click on the Save icon to save the settings. You should see the following page:

Next, click on the restart icon and perform the graceful restart to implement the changes.

Now, you can access your OpenLiteSpeed web server using the URL http://your-server-ip.

Create Virtual Hosts in OpenLiteSpeed

In the left pane, click on the Virtual Hosts button and click on the zoom icon. You should see the following page:

Provide all the information and click on the Save icon. You should see an error saying config file does not exist in the following screen:

To resolve this error, click on the CLICK ON CREATE to creates a virtual host configuration file. After the successful creation, you should see the following screen:

Now, click on the Save icon. You should see your virtual hosts in the following screen:

Next, click on the Virtual Hosts => Choose your virtual hosts (test.example.com) => General. You should see the following screen:

Provide your Document Root, Domain Name, Enable Compression and click on the Save icon.

Next, click on the Virtual Hosts => Choose your virtual hosts (test.example.com) => General => Index Files. You should see the following screen:

Provide your index filename and click on the Save icon.

Next, click on the Virtual Hosts => Choose your virtual hosts (test.example.com) => Log => Virtual Hosts Log. You should see the following screen:

Provide log file location, other required details and click on the Save icon.

Next, click on the Virtual Hosts => Choose your virtual hosts (test.example.com) => Log => Access Log. You should see the following screen:

Provide your log file location, other required details and click on the Save icon.

Next, click on the Virtual Hosts => Choose your virtual hosts (test.example.com) => Security => Access Control. You should see the following screen:

Type * to allow everyone to access web pages and click on the Save icon.

Map Virtual Host in OpenLiteSpeed

Next, you will need to map the virtual host with your domain name to access it via fully qualified domain.

To do so, click on the Listeners and click on the zoom icon. You should see the following screen:

In the Virtual Host Mappings, click on the + icon. You should see the following page:

Provide your domain name and click on the Save icon. You should see the following page:

Create Document Root for OpenLiteSpeed

Next, you will need to create a document root, log directory and index page for the OpenLiteSpeed.

First, create a document root and log directory with the following command:

mkdir /usr/local/lsws/test.example.com
mkdir /usr/local/lsws/test.example.com/html
mkdir /usr/local/lsws/test.example.com/logs

Next, create a index page with the following command:

echo "Welcome to OpenLiteSpeed Web Server running on CentOS 8 Operating System" > /usr/local/lsws/test.example.com/html/index.html

Next, click on the restart icon and perform a graceful restart to apply the changes.

Next, click on the Dashboard => Virtual Hosts, then stop Example virtual host and start test.example.com virtual host as shown below.

Test OpenLiteSpeed Virtual Hosts

At this point, virtual host test.example.com is configured for OpenLiteSpeed. It's time to access the virtual hosts.

Open your web browser and type the URL http://test.example.com. You will be redirected to the web page which we created earlier:

Congratulations! you have successfully installed and configured the OpenLiteSpeed web server on CentOS 8 server. You can now easily create your website using the OpenLiteSpeed admin interface.

Share this page:

Suggested articles

0 Comment(s)

Add comment