How to Install OpenLiteSpeed, PHP 7.0 & MariaDB on CentOS 7 / RHEL 7

0

OpenLiteSpeed is an open source web server developed by LiteSpeed Technologies, an open source version of commercial LiteSpeed web server.

OpenLiteSpeed is a high-performance HTTP server, and it can handle hundreds and thousands of simultaneous connections with very low resource consumptions.

OpenLiteSpeed is available for Linux, OS X, Solaris, and FreeBSD. It supports both SPDY/3.1 and HTTP/2 network protocols.

Features of OpenLiteSpeed

  • High performance, event-driven architecture.
  • Lightweight, minimal CPU and memory usage.
  • Apache compatible rewrite rules.
  • WebAdmin GUI.
  • Enhancement through available modules.
  • It allows a creation of virtual hosts.
  • Ships with Web proxy for page caching.
  • It supports several different versions of PHP.
  • Real-Time stats of web server

Setup OpenLitespeed Repository

OpenLiteSpeed is not available in CentOS 7 software repositories, so you have to add the OpenLiteSpeed repository.

Use the following command to add the OpenLiteSpeed repository.

rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm

Output:

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

Install openLiteSpeed on CentOS 7:

Now, install OpenLiteSpeed 1.4.26 (chck) using YUM command.

yum -y install openlitespeed

Run the following command to check the version of OpenLiteSpeed and its modules.

/usr/local/lsws/bin/lshttpd -v

Output:

LiteSpeed/1.4.26 Open
        module versions:
        modpagespeed 1.4.24-1.11.33.3
        cache 1.54
        modinspector 1.1
        uploadprogress 1.1

Controlling OpenLiteSpeed

To Start OpenLiteSpeed, run:

/usr/local/lsws/bin/lswsctrl start

To Stop OpenLiteSpeed, run:

/usr/local/lsws/bin/lswsctrl stop

To Restart OpenLiteSpeed, run:

/usr/local/lsws/bin/lswsctrl restart

To check the running status of OpenLiteSpeed, run:

/usr/local/lsws/bin/lswsctrl status

Output

litespeed is running with PID 3396.

By default, OpenLiteSpeed listens on port 8088. So, you need to add firewall rules to allow port 8088 for accessing the web server.

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

Enter the URL with port no 8088 and see whether you can able to access OpenLiteSpeed or not.

http://localhost:8088

OR

http://your-ip-addr-ess:8088
Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed Welcome Page
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed Welcome Page

The above page confirms you that the OpenLiteSpeed is running properly

Install MariaDB Server

We will now install the MariaDB server by using YUM command.

yum -y install mariadb mariadb-server

Start MariaDB server.

systemctl start mariadb

Set MariaDB service to start during every boot.

systemctl enable mariadb

Next, make the MariaDB server secure by using the mysql_secure_installation command.

Install PHP

As said in features of OpenLiteSpeed, it supports different versions of PHP installation, so we will configure OpenLiteSpeed with both PHP v5.6 and V7.0. Add EPEL repository for getting dependent packages for PHP.

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Choose either one of the PHP version for configuring OpenLiteSpeed.

OpenLiteSpeed with PHP 5.6 support:

yum install -y lsphp56 lsphp56-common lsphp56-mysql lsphp56-gd lsphp56-process lsphp56-mbstring lsphp56-xml lsphp56-mcrypt lsphp56-pdo lsphp56-imap lsphp56-soap lsphp56-bcmath

OpenLiteSpeed with PHP 7.0 support:

yum install lsphp70 lsphp70-common lsphp70-mysqlnd lsphp70-gd lsphp70-process lsphp70-mbstring lsphp70-xml lsphp70-mcrypt lsphp70-pdo lsphp70-imap lsphp70-soap lsphp70-bcmath

Configure OpenLiteSpeed

In this section, we will setup OpenLiteSpeed with both PHP 5.6  & PHP 7.0, Also we will configure OpenLiteSpeed to listen on standard HTPP port 80 and via WebAdmin console.

By Default, WebAdmin console listens on port 7080 and tThe default account of OpenLiteSpeed is,

Username: admin
Password: 123456

I recommend you to change the default password for security reason. To change the password of OpenLigtSpeed admin console, run the following command.

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

Output:

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: Enter Password
Retype password: Re Enter Password
Administrator's username/password is updated successfully!

Firewall

Update firewall rules to allow port 7080 and 80 to access WebAdmin console and Web server.

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

Access WebAdmin Console

Open a web browser and visit the following URL.

http://localhost:7080

OR

http://your-ip-add-ress:7080

Login with the admin account and the password you set few steps before.

Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed WebAdmin Console
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed WebAdmin Console

Dashboard:

Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed WebAdmin Console Dashboard
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed WebAdmin Console Dashboard

Configure OpenLiteSpeed with PHP 5.6:

You do not have to do any configuration changes to OpenLiteSpeed as it uses PHP 5.6 by default.

Configure OpenLiteSpeed with PHP 7.0:

As I said earlier, OpenLiteSpeed uses PHP 5.6. To have PHP 7.0 with OpenLiteSpeed, follow the below steps.

We already have PHP 7.0 on the server. So, go to “Server Configuration” –> “External App” –> “Add“.

Install OpenLiteSpeed on CentOS 7 - Add External App
Install OpenLiteSpeed on CentOS 7 – Add External App

Select “LiteSpeed SAPI App” and then click Next,

Install OpenLiteSpeed on CentOS 7 - New External App
Install OpenLiteSpeed on CentOS 7 – New External App

Add the below configuration,

Name: lsphp7
Address: uds://tmp/lshttpd/lsphp.sock
Max Connections : 35
Environment: PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35
Initial Request Timeout (secs) : 60
Retry Timeout (secs): 0
Persistent Connection: Yes
Response Buffering: No
Auto Start : Yes
Command: /usr/local/lsws/lsphp70/bin/lsphp
Back Log: 100
Instances: 1
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 400
Process Hard Limit: 500
Install OpenLiteSpeed on CentOS 7 - PHP 7 External App Configuration
Install OpenLiteSpeed on CentOS 7 – PHP 7 External App Configuration

Click save button to save the configuration.

Modify the default script handler to use PHP 7.0. To do that, go to “Server Configuration” –> “Script Handler” –> Edit lsphp5.

Install OpenLiteSpeed on CentOS 7 - Edit Script Handler
Install OpenLiteSpeed on CentOS 7 – Edit Script Handler

Update with the following configurations.

Suffixes: php
Handler Type: liteSpeed SAPI
Handler Name: lsphp7
Install OpenLiteSpeed on CentOS 7 - Script Handler Configuration
Install OpenLiteSpeed on CentOS 7 – Script Handler Configuration

Click the save icon.

Configure OpenLiteSpeed to use port 80:

Go to “Listeners” and click on “Zoom icon” in the Default listener to view the configuration.

Install OpenLiteSpeed on CentOS 7 - Listeners List
Install OpenLiteSpeed on CentOS 7 – Listeners List

Edit the listener.

Install OpenLiteSpeed on CentOS 7 - Editing Default Listener
Install OpenLiteSpeed on CentOS 7 – Editing Default Listener

Update with the following information.

IP Address: ANY
Port : 80
Install OpenLiteSpeed on CentOS 7 - Modifying Default Listener Configuration
Install OpenLiteSpeed on CentOS 7 – Modifying Default Listener Configuration

Click on the save icon.

Finally, restart the OpenLiteSpeed server.

Install OpenLiteSpeed on CentOS 7 - Restarting OpenLiteSpeed Server
Install OpenLiteSpeed on CentOS 7 – Restarting OpenLiteSpeed Server

Verify OpenLiteSpeed server:

Just enter the URL without port number and see whether you can able to access OpenLiteSpeed.

http://localhost/

OR

http://your-ip-addr-ess/
Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed Welcome Page on Port 80
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed Welcome Page on Port 80

The above page confirms that the OpenLiteSpeed is listening on Standard HTTP port 80.

Verify support for PHP in OpenLiteSpeed

Visit the following URL using your favorite web browser.

http://localhost/phpinfo.php

OR

http://your-ip-addr-ess/phpinfo.php

You can see the output like below.

Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed PHP Support
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed PHP Support

Scroll further down to see modules enabled in PHP.

Install OpenLiteSpeed on CentOS 7 - OpenLiteSpeed MySQL Support
Install OpenLiteSpeed on CentOS 7 – OpenLiteSpeed MySQL Support

That’s All. In our next article, we will configure Virtual Hosts in OpenLiteSpeed web server.

You might also like