1. Home
  2. Cloud and Servers
  3. Virtual Servers (VPS)
  4. How to install OpenLiteSpeed with Let’s Encrypt (HTTPS), PHP and MySQL in Ubuntu 20.04 LTS

How to install OpenLiteSpeed with Let’s Encrypt (HTTPS), PHP and MySQL in Ubuntu 20.04 LTS

A freely available opensource webserver OpenLiteSpeed offers basic functions of its commercial older brother LiteSpeed Web Server Enterprise. Compatibility with web server Apache settings (mod_rewrite), much quicker speed of PHP (up to 3x faster then Apache) and HTTPS (up to 4x faster than Apache), visual administration interface instead of text configuration file and optimisation for WordPress (odkaz na kb instalace WP přes wp-cli) (one-click installation + LSCache for higher speed) – these are only few reasons for why should you try the OpenLiteSpeed.

This guide works for Linux operating system Ubuntu in version 20.04 LTS (Focal Fossa) (odkaz na blog ubuntu verze 20.04). It is an LTS version (Long Term Support), that was published on 23. 04. 2020 and is officially supported by software company Canonical for 5 years since publishing, till April 2025. Developers are focusing in LTS on security and hardware compatibility, for it to be used on enterprise level.

Installing OpenLiteSpeed

Firstly it is necessary to secure that all packages are up to date. Let’s install all updated software in two commands in one go:

sudo apt update && sudo apt upgrade

If the system finds updated packages, it will ask, if we want to install them:

Do you want to continue? [Y/n]

Press the key y if you want to start updating process or key n, if you do not want to update. Then press Enter.

OpenLiteSpeed shall be installed from the official repository from the developers:

wget -qO - https://rpms.litespeedtech.com/debian/lst_repo.gpg | sudo apt-key add -
echo "deb http://rpms.litespeedtech.com/debian/ focal main" | sudo tee /etc/apt/sources.list.d/openlitespeed.list
sudo apt update
sudo apt install openlitespeed

Press y to start the installation process. Then press Enter and wait for the installation to finish.

We will check if the OpenLiteSpeed is running:

http://IP_adresa:8088

This is how the welcome page that informs you about successful installation looks:

Files and directories located above can be edited in /usr/local/lsws/Example/html/

Installing current version of PHP

Along with OpenLiteSpeed is installed the version of PHP 7.3, but we would like the current version 7.4. We will install it this way:

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

Press y to start the installation process or n not to start it. Then press Enter and wait for the installation to finish.

Settings is provided in the visual interface in the web browser, that you need to set beforehand with a command:

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

We enter username tibor, password This.Is.strong:password and confirm the password. The successful completion of the task is shown by notification “Administrator’s username/password is updated successfully!”. On this address we will locate the administration settings:

http://IP_adresa:7080

You will display a notification about unsecure connection. This time we will continue contrary to the notification to set the OpenLiteSpeed to prevent this notification from reappearing:

Steps are shown and numbered in the picture.

We log in via above set name (tibor) and password heslom (This.Is.strong:password) and we change the port from 8088 to 80, so we wouldn’t need to enter colon with a port number (http://IP_adresa:8088 will change to http://IP_adresa):

The we will set the OpenLiteSpeed for it to user newest version of PHP we installed before (here from version 7.3 to version 7.4):

After the step 5. you will display an extensive form, that we will fill in this way (unmentioned items are to be left empty):

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

To save the filled in values, select the diskette symbol on the top right.

WE have created a new external application under the name lsphp74 and now we set the OpenLiteSpeed to use it and then select the green icon on the top to restart the server:

On the address http://IP_adresa/phpinfo.php we see in the title above, that OpenLiteSpeed uses the PHP version 7.4.

Secured connection via HTTPS

OpenLiteSpeed requires for a secured connection a key and self-signed certificate and key from the certificate authority Let’s Encrypt.

openssl req -x509 -days 365 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes

To all fields you can simply press Enter, to fill in empty value.

Install a Certbot tool, that will allow you to automatize the process of creating, signing, installing and renewing of the certificate from Let’s Encrypt, all for free:

sudo apt install certbot

Here we will create a certificate for a domain (here vps.websupport.tech), that we have connected with IP address of the server:

sudo certbot certonly --webroot -w /usr/local/lsws/Example/html/ -d vps.websupport.tech

Enter your e-mail and confirm with Enter, then press A and confirm with Enter. At the end press N and confirm with Enter.

Certificate from the certificate authority Let’s Encrypt for your domain (here vps.websupport.tech) is created and now we set the OpenLiteSpeed to use it. Start by adding secured channel, that will receive the demands on the port 443:

No assign the domain (here vps.websupport.tech) to your virtual hosting (here with the name Example) on your secured channel (SSL):

We will enter the path to the private key (key.pem) and to the self-signed certificate (cert.pem). Name of the account (here tibor) may differ and it is necessary to take that into account when you enter the paths:

Enter the path to the private key (privkey.pem) and to the certificate (fullchain.pem) from the certificate authority of Let’s Encrypt. Name of the domain (here vps.websupport.tech) may differ and it is necessary to take that into account when you enter the paths:

Restart the OpenLiteSpeed with the green button on the top right. Then enter the domain name to the web browser (here vps.websupport.tech) via secured connection (HTTPS) like this:

https://vps.websupport.tech

Displayed website should inform you, that it is connected via secured connection and has a valid certificate. In the web browser select on the lock icon left to the domain name:

Installing database server MySQL

OpenLiteSpeed can now cooperate with PHP language in the current version, that is available to communicate with MySQL database. Let’s Install MySQL, so we could save data there via PHP. One command is what is needed:

sudo apt install mysql-server

Press y. Then press Enter and wait for the installation to finish.

For the security reasons we would recommend to run the following script after the MySQL installation:

sudo mysql_secure_installation

In all steps we acknowledge all questions with y and press Enter. In the process of the script you will set “password validation policy” to MEDIUM (number 1 + Enter) and password for root account for the MySQL (which is not the same as root in Linux). Password should contain at least 8 characters – lower and upper case, numbers and special symbols like dot, comma, at, questionmark, exclamation mark, etc.

Then we need to set the new user with restricted rights (we will not use root). Start the co communication with the database server MySQL:

sudo mysql

create a new user (here tibor), and set a strong password ktorému priradíme dostatočne silné heslo (tu This.Is.strong:password). In the password we use at least 8 characters – lower and upper case, numbers and special characters like dot, comma, colon, at, questionmark, exclamation mark,…

create user 'tibor'@'localhost' identified by 'Toto.Hes1o.je:silne';

We create a new database test:

create database test;

and to a user tibor we will give all rights for working with the database:

grant all privileges on test.* to 'tibor'@'localhost';
flush privileges;

We will end the work with MySQL server by:

exit

Summary

We have installed, above all, a quickening web server OpenLiteSpeed with a support for current PHP version and free security certificate Let’s Encrypt. Thanks to that we have increased the speed of loading of your website for both static and dynamic version. We have prepared a MySQL database, so we could use PHP language to write down data to the database. With OpenLiteSpeed we have gain an option to install WordPress with one click.

Updated on June 21, 2021

Was this article helpful?

Related Articles