How to Install OpenLiteSpeed and PHP 7 on CentOS 7

Updated on February 10, 2017
How to Install OpenLiteSpeed and PHP 7 on CentOS 7 header image

OpenLiteSpeed, the open source edition of LiteSpeed, is a high performance yet light-weight web server application.

In this article, I will introduce to you how to install OpenLiteSpeed along with PHP 7 on a CentOS 7 server.

Prerequisites

  • A CentOS 7 x64 server instance.
  • A sudo user.

Step 1: Update the system

Log in as a sudo user, and then update the system as follows:

sudo yum install epel-release -y
sudo yum clean all && sudo yum update -y && sudo shutdown -r now

After the reboot, log back in using the same sudo user.

Step 2: Install OpenLiteSpeed

On CentOS 7, you can install OpenLiteSpeed 1.4.24, the latest release of OpenLiteSpeed, using YUM:

sudo rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
sudo yum install openlitespeed -y

Step 3: Install PHP 7

When installing pre-compiled PHP packages for OpenLiteSpeed using YUM, you should choose PHP packages whose names start with lsphp.

For example, you can list all packages starting with lsphp using the below command:

yum list lsphp*

Then you can install some of the most commonly used PHP 7.1 packages and modules for OpenLiteSpeed as follows:

sudo yum install lsphp71 lsphp71-mysqlnd lsphp71-common lsphp71-gd lsphp71-pdo lsphp71-process lsphp71-mbstring lsphp71-mcrypt lsphp71-opcache lsphp71-bcmath lsphp71-xml -y

Step 4: Setup admin credentials for OpenLiteSpeed WebAdmin GUI

OpenLiteSpeed comes with a user-friendly WebAdmin UI. Before you can use the UI, you need to setup the admin user credentials as follows:

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

Provide info as below:

  • User name [admin]: <your-admin-username>
  • Password: <your-admin-password>
  • Retype password: <your-admin-password>

Allow port 7080 in order to allow web access to the WebAdmin GUI:

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

Now, point your web browser to http://203.0.113.1:7080, ignore the SSL security warning, and then use the admin credentials you set earlier to sign in.

Step 5: Configure OpenLiteSpeed in the WebAdmin GUI

By default, OpenLiteSpeed 1.4.24 expects that you are running PHP 5.x. Since we choose to use PHP 7.1, we need to modify OpenLiteSpeed's configurations to support PHP 7.1 as follows:

  1. Click the Server Configuration category and then the External app tab, you will find an external application named lsphp5. Click the second icon Edit on the right hand side in order to edit this application as follows:
  • Name: lsphp71
  • 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 : 0
  • Response Buffering: no
  • Auto Start: yes
  • Command: $SERVER_ROOT/lsphp71/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

Click the Save icon in the top right corner to save your modifications.

  1. Click the Script handler tab, and then use the Edit icon to update the script handler as follows:
  • Suffixes: php
  • Handler Type: LiteSpeed SAPI
  • Handler Name: lsphp71

After the modification, click the Save icon to save your changes.

  1. Click the Listeners category, and then use the View icon to see the details of the Default listener.

In the Listener Default > General page, click the Edit icon on the right hand side, and then modify the settings as below:

  • Listener Name: Default
  • IP Address: ANY
  • Port: 80

After the modification, click the Save icon to save your changes.

  1. Click the Graceful Restart icon in the top right corner to apply your changes.

Step 6: Confirm your settings

First, modify firewall rules in order to allow access on port 80:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Next, visit http://203.0.113.1 in a new web browser window. If everything goes well, you will see the Congratulations page which announces that:

You have successfully installed the OpenLiteSpeed Web Server!

Finally, visit http://203.0.113.1/phpinfo.php to learn more details about your OpenLiteSpeed setup.

That concludes our tutorial. Thanks for reading.