How to Install and Configure OpenLiteSpeed with PHP 7.4 on CentOS 8

OpenLiteSpeed is an open-source HTTP server developed by LiteSpeed Technologies. It is a high-performance and lightweight HTTP server with a web-based GUI for administration.

OpenLiteSpeed can handle more than a hundred thousand concurrent connections with low resource consumption (CPU and RAM) and supports many operating systems such as Linux, Mac OS, FreeBSD, and SunOS. The server can be used to run web page scripts written in PHP, Ruby, Perl, and Java.

In this tutorial, we will show you how to install OpenLiteSpeed with the MariaDB database and the current PHP 7.4 on the current CentOS 8 server.


For this guide, we will be using the latest CentOS 8 server with 2GB of RAM, 25GB free disk space, and 2 CPUs.

What we will do:

  • Install OpenLiteSpeed
  • Install PHP 7.4 OpenLiteSpeed Version
  • Install MariaDB Database
  • Setup OpenLiteSpeed Admin
  • Configure OpenLiteSpeed with PHP 7.4
  • Running OpenLiteSpeed on Port 80
  • Testing

Step 1 - Install OpenLiteSpeed

First, we will add the openliteSpeed repository and install the OpenLiteSpeed web server from it.

Add the OpenLiteSpeed repository for CentOS 8 using the command below.

rpm -Uvh

After that, check all available repository on the CentOS system.

dnf repolist

And you will get the result as below.

Check repositories with dnf

As a result, you've added the OpenLiteSpeed repository to the CentOS 8 system.

Now install the OpenLiteSpeed package using the dnf command below.

sudo dnf install openlitespeed

Once the installation is complete, start the OpenLiteSpeed service and add it to the system boot.

systemctl start lsws
systemctl enable lsws

Now check the openlitespeed service.

systemctl status lsws

OpenLitespeed is up and running on the CentOS 8 system.

Start OpenLitespeed on CentOS

As a result, you've installed the openlitespeed web server to the CentOS 8 server.

Step 2 - Install PHP 7.4

After installing the openlitespeed web server, we will install the latest PHP 7.4 for the openlitespeed called 'LSPHP' or (LSAPI and PHP).

Before installing PHP 7.4 packages, add the EPEL repository to the system.

sudo dnf install epel-release

After that, install LSPHP packages from the official OpenLitespeed repository using the following command.

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

Once the installation is complete, check the PHP sock file using the netstat command below.

netstat -pl | grep lsphp

And the PHP 7.4 for OpenLitespeed is up and running.

Check lsphp

As a result, you've installed PHP 7.4 packages for openlitespeed web server.

Step 3 - Install MariaDB

In this step, we will install the MariaDB server and set up its root password.

Install the MariaDB server using the dnf command below.

sudo dnf install mariadb mariadb-server

Once the installation is complete, start the MariaDB service and add it to the boot time.

systecmtl start mariadb
systemctl enable mariadb

Now the MariaDB service is up and running.

Next, we will set up the root password for the database server. And we will use the 'mysql_secure_installation' command-line tool for it.

Installing MariaDB

Run the 'mysql_secure_instalaltion' command below.


Now type the root password and type 'Y' for the rest of all configuration.

Set a root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

And the configuration MariaDB root password is completed.

Now log in to the MySQL shell using the root user as below.

mysql -u root -p
Type Your Root Password:

Once you've logged in, check the user on the MariaDB system using the following query.

select User, Password, Host from mysql.user;

And you will get the result as below.

Set MySQL root password

As a result, you've successfully installed the MariaDB database server and set up the root password authentication for it.

Step 4 - Setup Admin Authentication

OpenLiteSpeed provides a web-based dashboard for managing its configuration.

In this step, we will open port '7080' on the firewalld rules and set up the user and password authentication for the OpenLiteSpeed dashboard.

By default, the openlitespeed dashboard is running on port '7080'. And we will add the port '7080' to the firewalld.

Add port '7080' to the firewalld rules and reload the service using the 'firewall-cmd' command below.

firewall-cmd --add-port=7080/tcp --permanent
firewall-cmd --reload

And you've added the OpenLitespeed dashboard port '7080' to the CentOS firewalld.

Next, we will set up the OpenLitespeed dashboard authentication.

Go to the '/usr/local/lsws/admin/misc' directory and run the '' script.

cd /usr/local/lsws/admin/misc

Type your admin user and password, and you've set up the authentication for the OpenLitespeed admin dashboard.

Protect OpenLitespeed admin dashboard

Now open your web browser and type the server IP address followed by the port '7080' on the address bar.

Log in with your user and password.

Login to OpenLitespeed

Once the user and password are correct, you will get the OpenLitespeed admin dashboard as below.

OpenLitespeed admin dashboard

As a result, you've successfully setup the openlitespeed admin authentication.

Step 5 - Configure OpenLiteSpeed with PHP 7.4

In this step, we will set up the PHP 7.4 for the OpenLiteSpeed using the web-based administration.

On the OpenLiteSpeed dashboard, click the 'Server Configuration' menu on the left and click the 'External App' tab.

Configure OpenLiteSpeed with PHP 7.4

To add the new PHP 7.4 configuration, click the add '+' button on the right.

For the type, choose the 'LiteSpeed SAPI App' and click the 'Next' button.

LiteSpeed SAPI App

Now type details configuration as below.

Name: lsphp74
Address: uds://tmp/lshttpd/lsphp.sock
Notes: lsphp74 for OpenLiteSpeed
Max Connections: 35
Initial Request Timeout (secs): 60
Retry Timeout (secs): 0
Command: $SERVER_ROOT/lsphp74/bin/lsphp

And click the 'Save' button, and the PHP 7.4 configuration has been added.

PHP 7.4 configuration

Next, we will change the default PHP for OpenLiteSpeed to the PHP 7.4 version.

On the 'Server Configuration' menu, click the 'Script Handler' tab.

Script Handler

Now click the 'Edit' button on the action section.

On the 'Handler Name', choose the 'lsphp74' that we just added and click the 'Save' button.


And as a result, you've added and enabled the PHP 7.4 configuration for OpenLiteSpeed.

PHP 7.4 configuration for OpenLiteSpeed

Step 6 - Running OpenLiteSpeed on Port 80

By default, the OpenLiteSpeed is running on default port '8088'. To run the OpenLiteSpeed on default http port '80', we can use the administration dashboard to change the configuration.

In this step, we will add the HTTP and HTTPS service to the firewalld services list and set up the OpenLitespeed to run on the http port '80'.

Add the HTTP and https services to the firewalld using the following command.

firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent

Now reload the firewalld.

firewall-cmd --reload

And you've added the HTTP and HTTPS services to the firewalld.

Configure Firewalld

Next, back to the OpenLitespeed admin dashboard on your web browser and click the 'Listener' menu on the left.

OpenLitespeed Listeners

On the 'Default' listeners, click the 'view' button.

On the 'Address Settings' section, click the 'edit' button on the right side.

Address Settings

Now change the port to the default HTTP port '80' and click the 'Save' button.

Configure http port

And the default OpenLiteSpeed port has been changed to default HTTP port '80'.

Now click the restart button and the OpenLiteSpeed service will be restarted.

Restart Server after changing the configuration

As a result, the OpenLiteSpeed is now running on default HTTP port '80'.

Step 7 - Testing

Open your web browser and type the server IP address on the address bar.

And you will get the default index page of OpenLiteSpeed.

OpenLitespeed installed successfully

Next, we will test the PHP configuration and make sure it works.

On the 'Test PHP' section, click the button 'click here'.

And you will get the phpinfo page as below.

PHP info on OpenLitespeed

As a result, you've installed the OpenLiteSpeed web server with the MariaDB database and PHP 7.4 on CentOS 8 Server.


Share this page:

5 Comment(s)

Add comment

Please register in our forum first to comment.


By: Aleksandr

 sudo dnf install openlitespeed

Last metadata expiration check: 0:00:24 ago on Mon 24 Feb 2020 01:30:25 AM CET.


 Problem: package openlitespeed-1.6.9-1.el8.x86_64 requires lsphp73-mcrypt, but none of the providers can be installed

  - cannot install the best candidate for the job

  - nothing provides needed by lsphp73-pecl-mcrypt-1.0.3-1.el8.7.3.x86_64

(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

By: h

For the libmcrypt error, you will need to enable the centos alternate repo first - and then try this again

By: Carl

You have a typo: systecmtl start mariadb

It should be: systemctl start mariadb

By: Brent

For centos 8, need to add "dnf install lsphp74-json" to the list of php items to install.

By: Lucas

Is there any way to change the php version from the command line?

I want to install litespeed on a docker container with php7.4, but by default it installs php 7.3. I have managed to install php 7.4, but now I want to change the version lite speed is using.