How to install and configure OpenLiteSpeed ​​with PHP 7.4 on CentOS 8

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, lightweight HTTP server with a web-based GUI for management.

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

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

prerequisites

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

What we do:

  • Install OpenLiteSpeed
  • Install PHP 7.4 OpenLiteSpeed ​​version
  • Install MariaDB database
  • Setting up OpenLiteSpeed ​​administrator
  • Configure OpenLiteSpeed ​​with PHP 7.4
  • OpenLiteSpeed ​​on port 80
  • testing

Step 1-install OpenLiteSpeed

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

Use the following command to add the OpenLiteSpeed ​​repository for CentOS 8.

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

After that, check all available repositories on CentOS system.

dnf repolist

You will get the following results.

As a result, you have added the OpenLiteSpeed ​​repository to your CentOS 8 system.

Now, install the OpenLiteSpeed ​​package using the dnf command below.

sudo dnf install openlitespeed

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

systemctl start lswssystemctl enable lsws

Now check the openlitespeed service.

systemctl status lsws

OpenLitespeed is up and running on CentOS 8 systems.

Launch OpenLitespeed on CentOS

As a result, you have installed the openlitespeed web server on the CentOS 8 server.

Step 2-Install PHP 7.4

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

Add the EPEL repository to your system before installing the PHP 7.4 package.

sudo dnf install epel-release

After that, install the LSPHP package 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

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

netstat -pl | grep lsphp

And PHP 7.4 for OpenLitespeed is up and running.

Check lsphp

So you have installed the PHP 7.4 package for the openlitespeed web server.

Step 3-install MariaDB

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

Use the following dnf command to install MariaDB server.

sudo dnf install mariadb mariadb-server

After the installation is complete, start the MariaDB service and add it to the startup time.

systecmtl start mariadbsystemctl enable mariadb

The MariaDB service is now up and running.

Next, we will set the root password for the database server. And we will use the “mysql_secure_installation” command line tool.

Install MariaDB

Run the “mysql_secure_instalaltion” command below.

mysql_secure_installation

Now type the root password and then type “Y” for all other configurations.

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

At this point, configuring the MariaDB root password is complete.

Now log in to the MySQL Shell as the root user as shown below.

mysql -u root -pType Your Root Password:

After logging in, check the user on the MariaDB system using the following query.

select User, Password, Host from mysql.user;

You will get the following results.

Set MySQL root password

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

Step 4-Set up administrator authentication

OpenLiteSpeed ​​provides a web-based dashboard to manage its configuration.

In this step, we will open port “7080” in accordance with firewall rules and set up user and password authentication for the OpenLiteSpeed ​​dashboard.

By default, the openlitespeed dashboard runs on port “7080”. Then we add port “7080” to firewalld.

Add port “7080” to the firewalld rule and then reload the service using the “firewall-cmd” command below.

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

And you have added the OpenLitespeed dashboard port “7080” to the CentOS firewall.

Next, we will set up OpenLitespeed dashboard authentication.

Go to the “/ usr / local / lsws / admin / misc” directory and run the “admpass.sh” script.

cd /usr/local/lsws/admin/miscsh admpass.sh

Type your administrator user and password, and authentication has been set up for the OpenLitespeed Management Console.

Protecting the OpenLitespeed Management Console

Now, open your web browser and type the server IP address and port “7080” in the address bar.

https://10.5.5.25:7080/

Sign in with your username and password.

Login to OpenLitespeed

Once the username and password are correct, you will get the OpenLitespeed management console as shown below.

OpenLitespeed Management Dashboard

As a result, you have successfully set up openlitespeed administrator authentication.

Step 5-configure OpenLiteSpeed ​​with PHP 7.4

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

On the OpenLiteSpeed ​​dashboard, click “server configuration“Menu and click “External Applications” label.

Configure OpenLiteSpeed ​​with PHP 7.4

To add a new PHP 7.4 configuration, click Add ‘+“Button.

For Type, select “LiteSpeed ​​SAPI application‘,then click’next‘Button.

LiteSpeed ​​SAPI application

Now type the details configuration as shown below.

Name: lsphp74Address: uds://tmp/lshttpd/lsphp.sockNotes: lsphp74 for OpenLiteSpeedMax Connections: 35Initial Request Timeout (secs): 60Retry Timeout (secs): 0Command: $SERVER_ROOT/lsphp74/bin/lsphp

then click”saveButton and added PHP 7.4 configuration.

PHP 7.4 configuration

Next, we changed the default PHP of OpenLiteSpeed ​​to PHP 7.4 version.

in”server configurationIn the menu, click “Script handler‘Label.

Script handler

Now, click “edit‘Button on the operation section.

On “Handler Name”, select “lsphp74We just added ‘, and then clicked’save‘Button.

lsphp74

So you have added and enabled PHP 7.4 configuration for OpenLiteSpeed.

OpenLiteSpeed ​​PHP 7.4 configuration

Step 6-Run OpenLiteSpeed ​​on port 80

By default, OpenLiteSpeed ​​is on the default port “8088‘. To run OpenLiteSpeed ​​on the default http port “80”, we can use the management console to change the configuration.

In this step, we add HTTP and HTTPS services to the Firewalld services list and set OpenLitespeed to run on http port ’80’.

Use the following command to add HTTP and https services to firewalld.

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

Now reload the firewall.

firewall-cmd --reload

And you have added HTTP and HTTPS services to Firewalld.

Configure firewall

Next, return to the OpenLitespeed management console on your web browser and click “audience“The menu is on the left.

OpenLitespeed listener

in”default‘Audience, click’view‘Button.

in”Address setting“Section, click”edit‘Button.

Address setting

Now change the port to the default HTTP port ‘80‘,then click’save‘Button.

Configure http port

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

Now, click the restart button and the OpenLiteSpeed ​​service will restart.

Restart the server after changing the configuration

As a result, OpenLiteSpeed ​​now runs on the default HTTP port “80”.

Step 7- test

Open a web browser and type the server IP address in the address bar.

http://10.5.5.25/

You will then get the default OpenLiteSpeed ​​index page.

OpenLitespeed installed successfully

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

in”Test PHP‘Section, click the button’click here‘.

You will get the phpinfo page as shown below.

PHP information on OpenLitespeed

So you have installed the OpenLiteSpeed ​​web server with MariaDB database and PHP 7.4 on the CentOS 8 server.

reference

Sidebar