Install and Configure OpenLiteSpeed Web Server – LiteSpeed Web Server (LSWS), is a proprietary web server software. It is the 4th most popular web server, estimated to be used by 8.1% of websites as of December 2020. LSWS is developed by privately held LiteSpeed Technologies. The software uses the same configuration format as Apache HTTP Server and is compatible with most Apache features. An open source variant is also available
LiteSpeed was the first to introduce production-grade HTTP/3 web server support. But we didn’t stop there. As the new protocol continues to be defined, we are there at every step, keeping our implementation current and cutting-edge. All of our server products across the board feature HTTP/3 support.
Time needed: 30 minutes
How to install and configure OpenLiteSpeed web server on Ubuntu 20.04 | Debian 10
- Add LiteSpeed repository
First we need to add LiteSpeed repository to the operating system to enable official repository
$ wget -O – http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | sudo bash - Install OpenLiteSpeed
With the repository added you can install OpenLiteSpeed web server on Ubuntu 20.04 | Debian 10
$ sudo apt update
$ sudo apt-get install openlitespeed - Install LSPHP on Ubuntu | Debian
Install lsphp74 on Ubuntu | Debian
Install PHP 7.4 along with some additional packages.sudo apt install lsphp74 lsphp74-common lsphp74-mysql lsphp74-curl
Verify your PHP version$ /usr/local/lsws/lsphp74/bin/php7.4 -v
- Setting the Administrative Password
Setting the Administrative Password for Newly Installed Webserver, please use below command & follow the screen instructions.
$ sudo /usr/local/lsws/admin/misc/admpass.sh - Access OpenLiteSpeed Web Admin We Console
Access OpenLiteSpeed Web Admin We Console using http://your_ip_address:7080
- Switch HTTP port to default (port 80)
OpenLiteSpeed default port is 8088 and we need to change is to default HTTP port
Go to “Listeners” & view Default “Listener” – Click right top corner edit button
Change port 8088 > 80 & save changes - Configure LSPHP74
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.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.
Next, Go to the Script Handler tab and edit the lsphp handler. Switch the Handle name tolsphp74
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, visithttp://<YOURSERVERIP>/phpinfo.php
in your browser. - Setup Virtual Host
First, we need to create directories for our virtual host.$ sudo mkdir /v
ar/www/html/example.com/{p
ublic_html,logs} -p
Access the Virtual Hosts section from the left and click the Add button.
Virtual Host Name: example.com
Virtual Host Root:
public_html/v
ar/www/html/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
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.
Then, go to Virtual Hosts -> Choose Virtual Host(example.com) -> General and modify the configuration as given.Document Root:
public_html/v
ar/www/html/example.com/
Domain Name: example.com
Enable Compression: Yes
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
Go to the Log section and click Edit Virtual Host Log and fill the following values.Use Server’s Log: Yes
File Name:
/v
ar/www/html/example.com/
logs/error.logLog Level: ERROR
Rolling Size (bytes): 10M
Next we need to configure access log using below values.Log Control: Own Log File File
Name:
/v
ar/www/html/example.com/
logs/access.logPiped 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
Then we need to configure Access Control under the Security section. Set the following Values.Allowed List: *
Denied List: Not set
Next, we need to set the Script Handler Definition.Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: [Server Level]: lsphp74
Next, we need to set Rewrite Control under Rewrite section. Set the following values.Enable Rewrite: Y
esAuto Load from .htaccess:
Yes
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. - Setup Let’s Encrypt SSL
Let us create the Self Signed Certificate first.openssl req -x509 -days 365 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes
To use Let’s Encrypt, we need to install the Certbot tool.sudo apt install certbot
Obtain the SSL certificate.sudo certbot certonly --webroot -w
public_html -d example.com/v
ar/www/html/example.com/
Follow the Interactive prompt & note down SSL cert & key path to configure with listener & virtual host.
Now open the Admin console and go to Listeners >> Add New Listener and add the following values.Listener Name: SSL
IP Address: ANY
Port: 443
Secure: Yes
Next, go to Virtual Host Mappings section under the SSL Listener by clicking on SSL, click on the Add button and fill the following values.
Example :Virtual Host: example.com
Domains: example.com
Next, go to Listeners >> SSL Listener >> SSL Tab >>SSL Private Key & Certificate (Edit button) and fill the following values for the self-signed certificate we created before.
Next go to Virtual Hosts >> example.com >> SSL Tab >> SSL Private Key & Certificate (Edit button) and fill the following values with the Let’s Encrypt Certificate.Private Key File: /etc/letsencrypt/live/example.com/privkey.pem Certificate File: /etc/letsencrypt/live/example.com/fullchain.pem Chained Certificate: Yes
Install and Configure OpenLiteSpeed Web Server – just we are finished the configuration and you can enjoy OpenLiteSpeed server with HTTP/3 & QUIC support. Please visit HTTP/3 Check site to test your configuration.