openlitespeed2

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.

$ sudo apt update

$ sudo apt upgrade

Step 1 – Configure Firewall

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

$ sudo ufw allow OpenSSH

$ sudo ufw allow http

$ sudo ufw allow https

$ sudo ufw allow 7080/tcp

$ sudo ufw allow 8088/tcp

Now check the ufw status:

$ sudo ufw status

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

Status: active

To                         Action      From

--                         ------      ----

OpenSSH                    ALLOW       Anywhere                  

80/tcp                     ALLOW       Anywhere                  

443/tcp                    ALLOW       Anywhere                  

7080/tcp                   ALLOW       Anywhere                  

8088/tcp                   ALLOW       Anywhere                  

OpenSSH (v6)               ALLOW       Anywhere (v6)             

80/tcp (v6)                ALLOW       Anywhere (v6)             

443/tcp (v6)               ALLOW       Anywhere (v6)             

7080/tcp (v6)              ALLOW       Anywhere (v6)             

8088/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:

$ 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.

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

Add the Repository.

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

Update the Repository.

$ sudo apt update

Install OpenLiteSpeed

$ sudo apt install openlitespeed

Check the status of the server.

$ 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.

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

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

openlitespeed_Screenshot 2020-12-09 at 18.21.51

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.

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

Verify your PHP installation.

$ /usr/local/lsws/lsphp74/bin/php7.4 -v

PHP 7.4.5 (cli) (built: May  7 2020 23:08:38) ( NTS )

Copyright (c) The PHP Group

Zend Engine v3.4.0, Copyright (c) Zend Technologies

    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies

You can check for the enabled PHP modules.

$ /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.

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

Please specify the user name of administrator.
This is the user name required to login the administration Web interface.

User name [admin]: <username>

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!

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.

You will be greeted by the following screen.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

You will be greeted by the following screen.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

Name: lsphp74
Address: uds://tmp/lshttpd/lsphp.sock
Max Connections: 35
Environment: PHP_LSAPI_MAX_REQUESTS=500
             PHP_LSAPI_CHILDREN=35
             LSAPI_AVOID_FORK=200M
Initial Request Timeout (secs): 60
Retry Timeout : 0
Persistent Connection: Yes
Response Buffering: no
Start By Server: Yes(Through CGI Daemon)
Command: lsphp74/bin/lsphp
Back Log: 100
Instances: 1
Priority: 0
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 1400
Process Hard Limit: 1500

Click Save when finished.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

Step 6 – Setup Virtual Host

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

$ 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.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

Fill in the values as specified

Virtual Host Name: example.com
Virtual Host Root: $SERVER_ROOT/example.com/
Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
Follow Symbolic Link: Yes
Enable Scripts/ExtApps: Yes
Restrained: Yes
External App Set UID Mode: Server UID

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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.

Log Control: Own Log File
File Name: $VH_ROOT/logs/access.log
Piped Logger: Not Set
Log Format: Not Set
Log Headers: Not Set
Rolling Size (bytes): 10M
Keep Days: 30
Bytes log: Not Set
Compress Archive: Yes

openlitespeed_Screenshot 2020-12-09 at 18.26.58

Click Save when done. Next, we need to configure Access Control under the Security section. Set the following Values.

Allowed List: *
Denied List: Not set

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: [Server Level]: lsphp74

openlitespeed_Screenshot 2020-12-09 at 18.26.58

Next, we need to set Rewrite Control under Rewrite section. Set the following values.

openlitespeed_Screenshot 2020-12-09 at 18.26.58

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

openlitespeed_Screenshot 2020-12-09 at 18.26.58

Click Save when done. Now, click on the Graceful restart button 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)

Web server Requests per second
OpenLiteSpeed 39,689
Nginx 26,003

 

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

Web server Requests per second
OpenLiteSpeed 21,485
Nginx 10,674

 

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

Web server Requests per second
OpenLiteSpeed + LSCache 22,248
Nginx + FastCGI Cache 9220

 

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)

Web server Requests per second
OpenLiteSpeed 39,689
Apache 12,416

 

For the small static file delivery time the results were:

Web server Requests per second
OpenLiteSpeed 21,485
Apache 9647

 

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

 

WordPress + Cache

Web server Requests per second
OpenLiteSpeed + LSCache 22,248
Apache + W3 Total Cache 9220

 

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 to repeat our tests and see the results for yourself. We’re sure you’ll be pleasantly surprised.