What Is OpenLiteSpeed And How To Install It
Cloud computingJanuary 6, 2021Updated August 30, 20215 min read

What Is OpenLiteSpeed And How To Install It

Ever since its launch back in 2003, WordPress has become a global phenomenon. Today, most websites, from presentation sites to personal blogs, use WordPress as their Content Management System (CMS). In fact, WordPress websites make up 14.7% of the top 100 websites in the world.

Because of its ever-growing popularity, at one point, developers started to wonder whether Google actually favors WordPress websites over sites that use other Content Management Systems like Wix, Drupal, or Joomla. Although these myths have been debunked, they also revealed that, because of the way WordPress is built, it makes it easier for developers to follow all SEO best practices. And that’s the real reason why WordPress websites rank higher in Google.

Enter OpenLiteSpeed.

Speaking of SEO best practices, one of the most important aspects you should keep in mind if you want your website to rank high is Page Speed. So, if you’ve run Google’s PageSpeed Insights tool and you’re not happy with your results, it’s time to make some performance optimizations.

What is OpenLiteSpeed?

OpenLiteSpeed is a high-performance, lightweight, open-source HTTP server that helps your site load faster than ever. Because it’s developed and maintained by the same team responsible for LiteSpeed Web Server Enterprise, it contains all of the essential features of the enterprise version and the same high-quality coding standard.

A few of the characteristics that make OpenLiteSpeed better than other similar solutions are its:

  • High-performance, event-driven architecture
  • Super light-weight, minimal CPU and memory footprint
  • Apache-compatible rewrite rules
  • User-friendly WebAdmin GUI.

How to install OpenLiteSpeed?

Prerequisites:

Ubuntu 20.04 based server.

Update your system.

Text
$ sudo apt update 
$ sudo apt upgrade

Step 1 - Configure Firewall

We need to enable SSH, HTTP, HTTPS and ports 7080, 8088 for the firewall.

Text
1$ sudo ufw allow OpenSSH 
2$ sudo ufw allow http 
3$ sudo ufw allow https 
4$ sudo ufw allow 7080/tcp 
5$ sudo ufw allow 8088/tcp

Now check the ufw status:

Text
$ sudo ufw status

You should see an output similar to if ufw is enabled:

Text
1Status: active 
2To                         Action      From 
3--                         ------      ---- 
4OpenSSH                    ALLOW       Anywhere                   
580/tcp                     ALLOW       Anywhere                   
6443/tcp                    ALLOW       Anywhere                   
77080/tcp                   ALLOW       Anywhere                   
88088/tcp                   ALLOW       Anywhere                   
9OpenSSH (v6)               ALLOW       Anywhere (v6)              
1080/tcp (v6)                ALLOW       Anywhere (v6)              
11443/tcp (v6)               ALLOW       Anywhere (v6)              
127080/tcp (v6)              ALLOW       Anywhere (v6)              
138088/tcp (v6)              ALLOW       Anywhere (v6)

Otherwise, it will show that the status is inactive, if the status is inactive run the following command to enable it:

Text
$ sudo ufw enable

Step 2 - Install OpenLiteSpeed

We will use OpenLiteSpeed's official Repository for our tutorial which maintains 1.6.x version only.

Add the OpenLiteSpeed Repository Key.

Text
$ wget -qO - https://rpms.litespeedtech.com/debian/lst_repo.gpg | sudo apt-key add -

Add the Repository.

Text
$ echo "deb http://rpms.litespeedtech.com/debian/ focal main" | sudo tee /etc/apt/sources.list.d/openlitespeed.list

Update the Repository.

Text
$ sudo apt update

Install OpenLiteSpeed

Text
$ sudo apt install openlitespeed

Check the status of the server.

Text
$ sudo /usr/local/lsws/bin/lswsctrl status 
litespeed is running with PID 21825.

If it is not running, you can start with the following command.

Text
$ sudo /usr/local/lsws/bin/lswsctrl start

Open http://<YOURSERVERIP>:8088 to access your web server. You should see the following page.

Step 3 - Install PHP

OpenLiteSpeed server ships with PHP 7.3 which is pre-enabled. But we want to use PHP 7.4 so we will install our own copy.

Install PHP 7.4 along with some additional packages.

Text
$ sudo apt install lsphp74 lsphp74-common lsphp74-mysql lsphp74-curl

Verify your PHP installation.

Text
1$ /usr/local/lsws/lsphp74/bin/php7.4 -v 
2PHP 7.4.5 (cli) (built: May  7 2020 23:08:38) ( NTS ) 
3Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) 
4Zend Technologies 
5    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies

You can check for the enabled PHP modules.

Text
$ /usr/local/lsws/lsphp74/bin/php7.4 --modules

We will configure PHP to work with OpenLiteSpeed later.

Step 4 - Configure OpenLiteSpeed

Configure Admin Panel

Set the Administrator panel credentials.

Text
1$ sudo /usr/local/lsws/admin/misc/admpass.sh 
2Please specify the user name of administrator. 
3This is the user name required to login the administration Web interface. 
4User name [admin]: <username> 
5Please specify the administrator's password. 
6This is the password required to login the administration Web interface. 
7Password: 
8Retype password: 
9Administrator's username/password is updated successfully!

You can also use this command in case you forget your login details.

To access the administration panel, open http://<YOURSERVERIP>:7080.

On your first login, your browser will give warnings saying your connection is not private. Click Advanced and click "Accept the risk and Continue" (in case of Firefox) or "Proceed to <YOURSERVERIP>(unsafe)" (in case of Chromium-based browser). You won't see the warning again.

Switch HTTP port back to 80

Let us change the default HTTP port to 80. Log in to your administration panel at http://<YOURSERVERIP>:7080 with the credentials you just created.

Visit Listeners section from the left. You will see the default listeners with port 8088.

Click the View button to see details configuration. On the next page under Listener Default > General Page, click on the Edit icon and change the port from 8088 to 80.

Click Save and then restart the server by clicking on the Graceful restart button.

Step 5 - Configure PHP

In this step, we need to associate our copy of PHP 7.4 with the server.

Click on Server Configuration section on the left and then on the tab External App. You will see an existing LiteSpeed App for PHP 7.3. We will create our own LiteSpeed App for PHP 7.4. You can easily switch between them later on if you want.

Click on the Add button to create a new app. For the type, select LiteSpeed SAPI App and click on Next.

Next, add the configuration below. Leave all the other fields blank.

Text
1Name: lsphp74 
2Address: uds://tmp/lshttpd/lsphp.sock 
3Max Connections: 35 
4Environment:
5  PHP_LSAPI_MAX_REQUESTS=500
6  PHP_LSAPI_CHILDREN=35
7  LSAPI_AVOID_FORK=200M 
8Initial Request Timeout (secs): 60 
9Retry Timeout : 0 
10Persistent Connection: Yes 
11Response Buffering: no 
12Start By Server: Yes(Through CGI Daemon) 
13Command: lsphp74/bin/lsphp 
14Back Log: 100 
15Instances: 1 
16Priority: 0 
17Memory Soft Limit (bytes): 2047M 
18Memory Hard Limit (bytes): 2047M 
19Process Soft Limit: 1400 
20Process Hard Limit: 1500

Click Save when finished.

Now that we have created our own PHP 7.4 based app, we need to tell the server to start using it.

Go to the Script Handler tab and edit the lsphp handler. Switch the Handle name to lsphp74 from the drop-down menu.

Click Save and then restart the server by clicking on the Graceful restart button.

To test whether your PHP has been switched correctly, visit http://<YOURSERVERIP>/phpinfo.php in your browser.

Step 6 - Setup Virtual Host

First, we need to create directories for our virtual host.

Text
$ sudo mkdir /usr/local/lsws/example.com/{html,logs} -p

The html directory will hold the public files and the logs directory will contain server logs.

Next, open the Admin console and access the Virtual Hosts section from the left and click the Add button.

Fill in the values as specified

Text
1Virtual Host Name: example.com 
2irtual Host Root: $SERVER_ROOT/example.com/ 
3Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf 
4Follow Symbolic Link: Yes 
5Enable Scripts/ExtApps: Yes 
6Restrained: Yes 
7External App Set UID Mode: Server UID

Click on the Save button when finished. You will get an error because the configuration file doesn't exist as of now. Click on the link to create the configuration file.

Click the Save button again to finish creating the Virtual Host.

Once the virtual host is created, go to Virtual Hosts -> Choose Virtual Host(example.com) -> General and modify the configuration as given.

Text
Document Root: $VH_ROOT/html/ Domain Name: example.com Enable Compression: Yes

Click the Save button when finished. Next, we need to setup index files. Click the edit button against Index files below the General Section. Set the following options.

Text
Use Server Index Files: No Index files: index.php, index.html, index.htm Auto Index: No

Click Save when done. Next, we need to choose Log files. Go to the Log section and click Edit against Virtual Host Logand fill the following values.

Text
Use Server’s Log: Yes File Name: $VH_ROOT/logs/error.log Log Level: ERROR Rolling Size (bytes): 10M

You can choose the Log Level as DEBUG if you are on a production/development machine.

Click Save and then click the plus sign in the Access Log section to add a new entry. Fill in the following values.

Text
1Log Control: Own Log File 
2File Name: $VH_ROOT/logs/access.log 
3Piped Logger: Not Set 
4Log Format: Not Set 
5Log Headers: Not Set 
6Rolling Size (bytes): 10M 
7Keep Days: 30 
8Bytes log: Not Set 
9Compress Archive: Yes

Click Save when done. Next, we need to configureAccess Controlunder theSecuritysection. Set the following Values.

Text
Allowed List: * 
Denied List: Not set

Click Save when done. Next, we need to set theScript Handler Definition. Set the following values.

Text
1Suffixes: php 
2Handler Type: LiteSpeed SAPI 
3Handler Name: [Server Level]: lsphp74

Next, we need to set Rewrite Control under Rewrite section.

And at last, we need to set the Listeners. Go to the the Listeners section and click on View button against Default Listener. Then, click on the Add button against Virtual Host Mappingsto add a new mapping and set the following values.

Click Save when done. Now, click on theGraceful restartbutton to apply all the changes above and restart the server.

Now, if you’re happy with your current Page Speed, there’s no need to use OpenLiteSpeed. But if you’re not, here’s how it compares to other popular web servers.

Browse our help articles related to OpenLightSpeed:

  1. How to Access OpenLiteSpeed Web Admin Console

  2. How to Install WordPress with Openlitespeed

  3. How to Edit php.ini settings for OpenLiteSpeed server

  4. How to Customize HTTP headers on the OpenLiteSpeed server

  5. How to Configure OpenLiteSpeed to Show Real Clients IPs when Using Cloudflare

OpenLiteSpeed vs. Nginx

For this test, we’ve simulated 10,000 requests over 100 concurrent users, and we looked at how the web servers handled a small static file and a simple PHP script, and then we evaluated their WordPress performance.

Small static file (4 kb)

Webserver

OpenLiteSpeed 39,689 Requests per second

Nginx 26,003 Requests per second

In case you’re wondering how quickly can each server deliver small static files:

OpenLiteSpeed 21,485 Requests per second

Nginx 10,674 Requests per second

WordPress is a PHP-heavy application, so caching is strongly recommended. For this test, we paired each server with a caching option. Here are our results:

WordPress + Cache

Webserver

OpenLiteSpeed + LSCache 22,248 Requests per second

Nginx + FastCGI Cache 9220 Requests per second

OpenLiteSpeed vs. Apache

Then, we’ve run the same test for Apache as well. Here’s how it compared to OpenLiteSpeed:

 

Small static file (4 kb)

Webserver

OpenLiteSpeed 39,689 Requests per second

Apache 12,416 Requests per second

 

For the small static file delivery time the results were:

Webserver

OpenLiteSpeed 21,485 Requests per second

Apache 9647 Requests per second

 

And last but not least, you can see that OpenLiteSpeed easily outperforms Apache in all tests:

 

WordPress + Cache

Webserver

OpenLiteSpeed + LSCache 22,248 Requests per second

Apache + W3 Total Cache 9220 Requests per second

 

So, if you’re in the market for a new solution that can help you improve your website’s Page Speed, we strongly encourage you to give OpenLiteSpeed a try.

 

Not yet convinced? We recommend you repeat our tests and see the results for yourself. We’re sure you’ll be pleasantly surprised.