In this article, we will discuss the complete guide to installing OpenLiteSpeed on Ubuntu and CentOS, including how to add domains and block domains that are pointed to your server but not yet registered.
But what exactly is OpenLiteSpeed?
OpenLiteSpeed is an open-source web server designed to replace Apache. It offers better performance, stability, features, security, and configuration, and is easier to use than Apache.
How to Install OpenLiteSpeed
There are several steps you need to follow to install it and create your first website, including
- Firewall Configuration
- Install OpenLiteSpeed Server
- Configure Admin Password
- Domain Configuration
- Get SSL
- Install SSL for Admin Panel
- Install SSL for Website
For this process, it is recommended to use a user that already has sudo access and not to use the root user directly.
1. Firewall Configuration
Before installing OpenLiteSpeed (OLS), you need to ensure that ports 8088 and 7080 are allowed on the server, as you will need to access port 7080 to log in to the OLS admin panel.
If you have not installed a firewall, you can install it first.
sudo apt install ufwNote: If you are using services like AWS Lightsail, Google Cloud Platform, or similar, you will need to perform additional configuration. If you are using Google Cloud, you can follow this tutorial for firewall configuration..
If the firewall is not active and you want to enable it, as well as allow OLS ports, you can use this command.
sudo ufw allow 22,25,53,80,443,7080,8088/tcpsudo ufw default rejectsudo ufw enableIf using CentOS, you need to use firewalld to add ports and allow HTTP/HTTPS access.
sudo firewall-cmd --add-service={http,https} --permanentsudo firewall-cmd --add-port={8088/tcp,7080/tcp} --permanentsudo firewall-cmd --reload2. Install OpenLiteSpeed Server
To install the OpenLiteSpeed server on Ubuntu and CentOS, you need to add the OLS repository first, then update the repository.
For Ubuntu, you can add the OLS repository with this command (ensure wget is installed).
wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | sudo bashsudo apt updateIf you are using CentOS, you can use this command.
sudo rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpmsudo dnf install epel-releasesudo dnf updateIf you are using CentOS 7, you can change dnf to yum
After adding the repository, you can then install OLS on the server and specify the PHP version to use, for example, PHP 8.1.
For Ubuntu , use this command.
sudo apt install openlitespeed lsphp81 -yUse this command for CentOS
sudo dnf install openlitespeed lsphp81 -yUse yum if you are using CentOS 7.
At this point, we have installed OLS with PHP 8.1, but we need to tell our server which PHP version to use with OLS, so we need to create a softlink to the PHP version we just installed.
sudo ln -sf /usr/local/lsws/lsphp81/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5Important Note
- Change 81 according to the PHP version you are installing. For example, if you want to use PHP 7.4, you need to change lsphp81 to lsphp74
- Here is a list of PHP versions you can use: 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2
3. Configure Admin Password
Wondering where you can get the admin password? You can set or configure the admin password for logging into the OLS admin panel with this command.
sudo /usr/local/lsws/admin/misc/admpass.shYou will be asked to update the username and password. However, if you do not update the username and only update the password, the default username is admin.
After successfully changing the username and password, you will receive a success message.
Administrator's username/password is updated successfully!Now you can access the website by visiting your server's IP address, for example, https://192.168.168.168:8088
If you want to log in to the admin panel page, you can visit https://IP_Server:7080, for example, https://192.168.168.168:7080
After successfully logging in, you will be directed to the OLS dashboard page to manage your server.
4. Domain Configuration
In this step, we will not discuss how to point a domain to an IP, as every provider has a different menu for IP pointing. We will only discuss how to set limits on which domains can be directed to your server.
To perform IP pointing, you can consult your domain name provider.
Moving on to domain configuration, after you log in to the admin panel page, you can open the Listenersmenu, then in the Actions panel, click the View
icon. On the Listener page you selected, click the Edit menu on the virtual host Example
In the Domains column, change it to the domain name you want to add, for example, ols.wpgan.com (only one domain per listener).
After adding the domain, you need to perform a graceful restart by clicking the green reload icon to apply the changes.
At this point, you have successfully added the domain, but the website needs to be accessed using port 8088 and cannot be accessed if you are using Cloudflare. Therefore, you need to configure SSL so that the website can be accessed directly without adding a port and can use HTTPS, for example, https://ols.wpgan.com, not http://ols.wpgan.com:8088
5. Get SSL
Here we will use a free SSL from Let’s Encrypt with the help of certbot. If you have a paid SSL, you can upload or save your SSL directly to the server.
First, install certbot on your server according to the OS used.
Ubuntu
sudo apt install certbot -yCentOS
sudo dnf install certbot -yUse yum if you are using CentOS 7.
After certbot is successfully installed, you can request an SSL certificate for your domain (ensure your domain is connected to the server IP).
sudo certbot certonly --standalone -d nama-domainChange domain-name according to the domain name you connected to the server. For example, if your domain is ols.wpgan.com, you can change it to look like this.
sudo certbot certonly --standalone -d ols.wpgan.comNext, you will be asked to fill in some data such as an email contact, agreement to the terms of service, and sharing your email address with the Electronic Frontier Foundation (a partner of Let’s Encrypt).
If successful, you will receive a success message that looks something like this.
Save both lines that show the storage location of your website's SSL files.
- Certificate is saved at: /etc/letsencrypt/live/domain-name/fullchain.pem
- Key is saved at: /etc/letsencrypt/live/domain-name/privkey.pem
6. Install SSL for Admin Panel
Since you now have an SSL certificate saved on the server, you need to add that SSL to the server, especially to the admin panel, so you can open the admin panel using HTTPS.
To do this, first open the WebAdmin Settings → Listenersmenu, then click the View
button. Next, open the SSL tab and edit the SSL Private Key & Certificate
configuration. Fill in the available columns with the following format, or according to the location you obtained previously.
- Private Key File: /etc/letsencrypt/live/domain-name/privkey.pem
- Certificate File: /etc/letsencrypt/live/domain-name/fullchain.pem
- Chained Certificate: Yes
- CA Certificate Path: /etc/letsencrypt/live/domain-name/fullchain.pem
- CA Certificate File: /etc/letsencrypt/live/domain-name/fullchain.pem
*change domain-name with the domain name for which you obtained the SSL, for example, ols.wpgan.com
After saving, you may need to perform a graceful restart by pressing the restart button. Then, you can access the admin panel via https://nama-domain:7080
7. Install SSL for Website
Finally, so that your website can be accessed with HTTPS and without having to add port 8088, you can install SSL for the website.
To do this, you can open the Listeners → Select Listener (e.g., Default) → View
menu. Just like when adding SSL for the admin panel, you can then open the SSL tab and edit SSL Private Key & Certificate
. Fill in the available columns with the following format, or according to the location you used to save the SSL.
- Private Key File: /etc/letsencrypt/live/domain-name/privkey.pem
- Certificate File: /etc/letsencrypt/live/domain-name/fullchain.pem
- Chained Certificate: Yes
- CA Certificate Path: /etc/letsencrypt/live/domain-name/fullchain.pem
- CA Certificate File: /etc/letsencrypt/live/domain-name/fullchain.pem
*change domain-name with the domain name for which you obtained the SSL, for example, ols.wpgan.com
Now, before you perform a graceful restart, you can open the Generaltab, then edit Address Setting
Inside Address Setting, change the port 8088 to 443 and change the Secure option to Yes
Now you can visit your website with the installed SSL and no longer use port 8088, so you can access it directly through the domain name, for example, https://ols.wpgan.com
Next, you can install the script in the folder /usr/local/lsws/Example/html/
If you previously used a different virtual host name in step 4, for example, wpgan, you can install the script in the folder /usr/local/lsws/wpgan/html/
COMMENTS
Loading...