Install OpenLiteSpeed (HTTP), PHP 7 & MariaDB on CentOS 7

OpenLiteSpeed is a free and open source, super lightweight HTTP server for Unix-like operating systems including Linux and Windows OS as well – designed by LiteSpeed Technologies.

It is feature-rich; high performance HTTP server that can be used to manage hundreds of thousands of simultaneous connections without critical server load issues, and it also supports third-party modules via API (LSIAPI).

OpenLiteSpeed Features:

  • High performance, event-driven architecture.
  • Super light-weight, minimal CPU and memory resources.
  • Ships with Apache-compatible rewrite rules.
  • User friendly WebAdmin GUI.
  • Supports numerous modules to enhance its functionality.
  • Allows creation of virtual hosts.
  • Supports high-performance page caching.
  • Several different versions of PHP installation support.

In this article, we will explain how to install and configure OpenLiteSpeed – High Performance HTTP Web Server with PHP 7 and MariaDB support on CentOS 7 and RHEL 7.

Step 1: Enable OpenLitespeed Repository

1. First install and enable own OpenLitespeed Repository to install latest version of OpenLiteSpeed and PHP 7 using following command.

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

Step 2: Install OpenLiteSpeed on CentOS 7

2. Now install OpenLiteSpeed 1.4 (the latest version at the time of this writing) with the YUM package manager command below; this will install it under the /usr/local/lsws directory.

# yum install openlitespeed
Install OpenLiteSpeed on CentOS-7
Install OpenLiteSpeed on CentOS-7

3. Once installed, you can start and confirm the OpenLiteSpeed version by running.

# /usr/local/lsws/bin/lswsctrl start
# /usr/local/lsws/bin/lshttpd -v
Check OpenLiteSpeed Version
Check OpenLiteSpeed Version

4. By default, OpenLiteSpeed runs on port “8088, so you need update the firewall rules to permit port 8088 via the firewall to access OpenLiteSpeed default site on the server.

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

5. Now open a web browser and type the following URL to verify the default page of OpenLiteSpeed.

http://SERVER_IP:8088/ 
or 
http://localhost:8088
Verify OpenLiteSpeed Page
Verify OpenLiteSpeed Page

Step 3: Install PHP 7 for OpenLiteSpeed

6. Here, you need to enable the EPEL repository from which you will install PHP 7 with the following command.

# yum install epel-release

7. Then install PHP 7 and a few necessary modules for OpenLiteSpeed with the command below, it will install PHP as /usr/local/lsws/lsphp70/bin/lsphp.

# yum install lsphp70 lsphp70-common lsphp70-mysqlnd lsphp70-process lsphp70-gd lsphp70-mbstring lsphp70-mcrypt lsphp70-opcache lsphp70-bcmath lsphp70-pdo lsphp70-xml

Attention: You might have noticed that here PHP is not installed in the usual way, you must prefix it with ls because there is a distinct PHP for LiteSpeed.

8. To install additional PHP modules, use the command below to list all the available PHP modules.

# yum search lsphp70
Sample Output
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager, versionlock
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
 * base: centos.mirror.snu.edu.in
 * epel: mirror.premi.st
 * extras: mirrors.nhanhoa.com
 * rpmforge: mirror.veriteknik.net.tr
 * updates: centos.mirror.snu.edu.in
=============================================================================================== N/S matched: lsphp70 ================================================================================================
lsphp70-debuginfo.x86_64 : Debug information for package lsphp70
lsphp70-pecl-igbinary-debuginfo.x86_64 : Debug information for package lsphp70-pecl-igbinary
lsphp70.x86_64 : PHP scripting language for creating dynamic web sites
lsphp70-bcmath.x86_64 : A module for PHP applications for using the bcmath library
lsphp70-common.x86_64 : Common files for PHP
lsphp70-dba.x86_64 : A database abstraction layer module for PHP applications
lsphp70-dbg.x86_64 : The interactive PHP debugger
lsphp70-devel.x86_64 : Files needed for building PHP extensions
lsphp70-enchant.x86_64 : Enchant spelling extension for PHP applications
lsphp70-gd.x86_64 : A module for PHP applications for using the gd graphics library
lsphp70-gmp.x86_64 : A module for PHP applications for using the GNU MP library
lsphp70-imap.x86_64 : A module for PHP applications that use IMAP
lsphp70-intl.x86_64 : Internationalization extension for PHP applications
lsphp70-json.x86_64 : JavaScript Object Notation extension for PHP
lsphp70-ldap.x86_64 : A module for PHP applications that use LDAP
lsphp70-mbstring.x86_64 : A module for PHP applications which need multi-byte s
...

Step 4: Configure OpenLiteSpeed and PHP 7

9. Now configure OpenLiteSpeed and PHP 7, and then set the standard HTTP port 80 as explained below.

As we mentioned earlier on, OpenLiteSpeed comes with a WebAdmin console which is associated to port 7080.

Begin by configuring the admin username and password for the OpenLiteSpeed WebAdmin console; run the following command to do so:

# /usr/local/lsws/admin/misc/admpass.sh
Set OpenLiteSpeed Admin Account
Please specify the user name of administrator.
This is the user name required to login the administration Web interface.

User name [admin]: tecmint

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!

10. Next update firewall rules to permit port 7080 via the firewall to access the WebAdmin console.

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

11. Now open a web browser and type the following URL to access OpenLiteSpeed WebAdmin console.

http://SERVER_IP:7080
OR
http://localhost:7080

Enter the username and password you set above, and click on “Login“.

OpenLiteSpeed WebAdmin Login
OpenLiteSpeed WebAdmin Login
OpenLiteSpeed WebAdmin Dashboard
OpenLiteSpeed WebAdmin Dashboard

12. OpenLiteSpeed uses LSPHP 5 by default, you need to make a few changes to setup LSPHP 70 as explained below.

To do that, go to Server ConfigurationExternal AppAdd button on the right side to add new “lsphp70” as shown in the screen shot below.

Add PHP 7 Support to OpenLiteSpeed
Add PHP 7 Support to OpenLiteSpeed

13. Then define External App, set type to “LiteSpeed SAPI App” and click next to add the new external application’s name, address, maximum number of connections, initial response timeout, and retry timeout.

Name: 					lsphp70
Address:    				uds://tmp/lshttpd/lsphp.sock
Notes: 					LSPHP70 Configuration 
Max Connections: 			35
Initial Request Timeout (secs): 	60
Retry Timeout : 			0
Set External App
Set External App
Configure External App
Configure External App

The most important config here is the Command setting which instructs the external app where to find PHP executable it will use; point it to the LSPHP70 installation:

 Command: 	/usr/local/lsws/lsphp70/bin/lsphp	

Then click on the Save button to save the above configurations.

14. Next, click on Server ConfigurationScript Handler and edit the default lsphp5 script handler, use the values below. Once you are done, save the settings.

Suffixes: 		php
Handler Type: 		LiteSpeed SAPI
Handler Name:		lsphp70
Notes:			lsphp70 script handler definition 
Configure Script Handler
Configure Script Handler

15. The default port HTTP servers normally listen on port 80, but for OpenLiteSpeed it is 8080: change it to 80.

Click on Listeners to see a list of all listeners configurations. Then click View to see all settings of the default listener and to edit, click Edit. Set the port to 80 and save the configuration and save the settings.

Set OpenLiteSpeed Port
Set OpenLiteSpeed Port

16. To reflect the above changes, gracefully restart OpenLiteSpeed by clicking on the restart button and click yes to confirm.

Restart OpenLiteSpeed Server
Restart OpenLiteSpeed Server

Step 5: Verify PHP 7 and OpenLiteSpeed Installation

17. Now test if the OpenLiteSpeed server is listening on port 80. Modify firewall rules to permit port 80 via the firewall.

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

18. Finally verify that OpenLiteSpeed is running on port 80 and PHP 7 using following URL’s.

http://SERVER_IP
http://SERVER_IP/phpinfo.php 

19. To manage and control OpenLiteSpeed service, use these commands.

# /usr/local/lsws/bin/lswsctrl start 		#start OpenLiteSpeed
# /usr/local/lsws/bin/lswsctrl stop   		#Stop OpenLiteSpeed 
# /usr/local/lsws/bin/lswsctrl restart 		#gracefully restart OpenLiteSpeed (zero downtime)
# /usr/local/lsws/bin/lswsctrl help 		#show OpenLiteSpeed commands

Step 6: Install MariaDB for OpenLiteSpeed

20. Install MariaDB database management system using following command.

# yum install openlitespeed mariadb-server

21. Next, start the MariaDB database system and secure its installation.

# systemctl start mariadb
# mysql_secure_installation

First, it will ask you to provide MariaDB root password, just press ENTER to set a new root password and confirm. For other questions, simply hit ENTER to accept the default settings.

You can find additional information from OpenLitespeed Homepage: http://open.litespeedtech.com/mediawiki/

You may also following related articles.

  1. Installing LAMP (Linux, Apache, MariaDB, PHP/PhpMyAdmin) in RHEL/CentOS 7.0
  2. Install Latest Nginx 1.10.1, MariaDB 10 and PHP 5.5/5.6 on RHEL/CentOS 7/6
  3. How To Install Nginx, MariaDB 10, PHP 7 (LEMP Stack) in 16.10/16.04
  4. How to Install LAMP with PHP 7 and MariaDB 10 on Ubuntu 16.10

In this article, we have explained you through the steps for installing and configuring OpenLiteSpeed with PHP 7 and MariaDB on a CentOS 7 system.

We hope that everything went on well, otherwise send us your queries or any thoughts via the comment section below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

4 Comments

Leave a Reply
    • For those who follow this tutorial on Google Cloud, for step 5 you can go to Google cloud console > in search bar type “firewall rules” > select firewall rules > change the “default-allow-http” from port “tcp:80” to “tcp:8088” > done.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.