
OpenLiteSpeed is a high-performance, open-source web server that supports protocols like HTTP/2 and HTTP/3, and natively integrates with PHP to serve dynamic web applications securely. It also offers a user-friendly graphical web administration console for managing virtual hosts.
This article explains how to install OpenLiteSpeed on Ubuntu 20.04 and configure the web administration console to securely deliver web applications on your server.
Before you begin:
Have an Ubuntu 20.04 server.
Set up a new A record for your domain that points to the server IP address.
Access the server using SSH as a non-root user with sudo privileges.
OpenLiteSpeed is not included in the default Ubuntu 20.04 APT repositories, but you can install it by adding the latest repository setup script. Follow these steps to download the repository script and install OpenLiteSpeed using the APT package manager.
Download the latest OpenLiteSpeed repository setup script.
Run the script to add the OpenLiteSpeed repository information to your APT sources.
Output:
Install OpenLiteSpeed.
View the installed OpenLiteSpeed version on your server.
Your output should be similar to the one below.
OpenLiteSpeed uses the lshttpd.service system service, with the alias lsws, to manage webserver processes using systemd. Follow the steps below to enable the OpenLiteSpeed service to start automatically at boot and start the webserver.
Enable the OpenLiteSpeed system service to automatically start at boot time.
Start the OpenLiteSpeed service.
View the OpenLiteSpeed service status and verify that it's running.
Output:
Stop the OpenLiteSpeed service.
Restart the service.
The OpenLiteSpeed web administration console runs on port 7080 by default, and the default administrator password is stored in the /usr/local/lsws/admin/password file. Follow the steps below to enable access to port 7080, change the default administrator credentials, and configure OpenLiteSpeed to serve web applications on HTTP port 80.
Run the OpenLiteSpeed administrator script to create a new custom username and password.
Enter a new administrator username in the User name prompt and press Enter to save the user.
Enter a strong password to use with your new administrative user.
Enter the user password again and press Enter to save your new administrative user details.
Allow connections to the OpenLiteSpeed web administration port 7080 through the default UFW firewall utility.
Reload the UFW rules to apply changes.
Access the OpenLiteSpeed port 7080 using your server IP in a web browser such as Chrome.
Accept the insecure SSL certificate warning and enter the administrative user details you created earlier.
<username you set earlier><password you set earlier>
Click Listeners on the main navigation bar to modify the default listening port on your webserver.
Click the view icon in the Actions section of the Default listener profile.
Click Edit in the top right of the Address Settings section to modify the default listener details.
Edit the Port field and replace the default value 8088 with 80 to enable all default virtual hosts to run on HTTP port 80.
Click the Save icon in the top right Address Settings section to save the new default listener settings.
Verify that a Configurations modified prompt displays. Then, find the LSWS PID option in the top right corner and click the Graceful Restart icon to apply your configuration changes.
Click Go when prompted to restart the OpenLiteSpeed webserver to apply changes.
OpenLiteSpeed allows you to create virtual hosts through its web administration console. To set up a new virtual host, log in to the console, navigate to Listeners, and add a new virtual host. Specify the domain (e.g., app.example.com) and the web root directory (e.g., /var/www/app.example.com). After saving, map the domain to the virtual host under the listener settings and restart the server for changes to take effect.
Create a new web root directory to use with your virtual host. For example, /usr/local/lsws/app.example.com.
Create the html, logs, and conf directories required by the OpenLiteSpeed webserver.
The command creates these sub-directories in the web root:
html: Stores the web application files for the virtual host.logs: Contains access and error logs for the virtual host.conf: Holds site-specific configurations for OpenLiteSpeed.Grant the OpenLiteSpeed console user and group lsadm full privileges to the web root directory.
Access your OpenLiteSpeed web administration console.
Click Virtual Hosts on the main navigation menu to set up a new virtual host.
Click the + Add option in the top right corner of the Virtual Host List section.
Enter the following virtual host configuration details in the respective fields. Replace app.example.com with your actual domain.
app.example.com$SERVER_ROOT/app.example.com/$SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.confYesYesYesServer UIDKeep the other virtual host values unchanged and click Save in the top right corner of the Virtual Host section to save changes.
Find and click the CLICK TO CREATE option when you receive a Please resolve the error(s) prompt to create a new vhconf.conf virtual host configuration in your web root directory.
Click Save to create the new virtual host configuration.
Verify that your new virtual host is available in the Virtual Hosts summary. Then, click View within the Actions section to modify the new virtual host information.
Navigate to the General tab and click Edit to modify the virtual host with the following information.
$VH_ROOT/html/app.example.comYesYes
Click Save to apply the new virtual host configuration.
Navigate to the Log tab and click Edit within the Virtual Host Log section. Then, enter the following values in the respective fields to set up the error log details.
Yes$VH_ROOT/logs/error.logERROR10M30
Click Save to apply the new virtual host error log details.
Click Add within the Access Log section to set up the virtual host access log details. Then, enter the following values in the respective fields.
Own Log File$VH_ROOT/logs/access.log10M30
Click Save to apply the new virtual host access log details.
Navigate to the Rewrite tab and click edit within the Rewrite Control section to set up the virtual host rewrite configurations.
Enable Rewrite: Yes
Auto Load from .htaccess: Yes
Click Save to apply your virtual host rewrite configurations.
Navigate to Listeners on the main navigation bar.
Edit the Default Listener and click Add within the Virtual Host Mappings section to set up your virtual host listening details.
Click the Virtual Host drop-down and select your virtual host profile.
Enter your domain app.example.com in the Domains field to bind with the virtual host and serve web application files.
Click Save to apply the new virtual host mapping details. Then, click the Graceful Restart next to LSWS PID in the top right console section to restart the OpenLiteSpeed webserver.
Click Go when prompted to restart LiteSpeed and apply your webserver configurations.
Access your server's SSH session.
Create a new HTML application file index.html in your web root html directory.
Add the following contents to the file.
Save and close the file.
The above HTML application displays a Greetings from Vultr message when accessed in your web browser.
Allow connections to the default HTTP port 80 through the firewall to test your virtual host configurations.
Access your virtual host domain in a new web browser window and verify that OpenLiteSpeed delivers your web application files.
OpenLiteSpeed serves virtual hosts on HTTP port 80 for unencrypted connections. To enable encrypted connections, use HTTPS on port 443 with SSL certificates. Follow the steps to generate trusted Let's Encrypt SSL certificates and secure your OpenLiteSpeed server.
Install the Certbot Let's Encrypt client tool using Snap.
Generate a new SSL Let's Encrypt SSL certificate using an HTTP-01 challenge and your virtual host web root directory. Replace app.example.com and admin@example.com with your actual details.
The command generates a Let's Encrypt SSL certificate for your domain app.example.com with the web root /usr/local/lsws/app.example.com/html/. Since Certbot doesn't support OpenLiteSpeed, you must manually enable the generated certificate in your virtual host configuration.
Your output should be similar to the one below when an SSL is successfully generated.
Test the Certbot SSL certificate renewal process.
Access your OpenLiteSpeed web administration dashboard.
Navigate to Listeners on the main navigation bar.
Click Add within the Listener List section to add a new listener.
Enter the following values in the respective field to listen for HTTPS requests on the server.
HTTPSANY IPv4443Yes
Click Save to add the new listener on your webserver.
Find the new HTTPS listener on your Listener list. Then, click View in the actions section to modify the listener details.
Click Add within the Virtual Host Mappings section to bind the listener to an existing virtual host on your server.
Enter the following details in the respective fields to bind your virtual host.
app.example.comapp.example.com
Click Save to apply the new virtual host mappings on your webserver.
Navigate to the SSL tab and click edit within the SSL Private Key & Certificate section to modify your certificate details.
Enter the following details in the respective fields to match your Let's Encrypt SSL certificate paths.
/etc/letsencrypt/live/app.example.com/privkey.pem/etc/letsencrypt/live/app.example.com/fullchain.pemYes
Click Save to apply the SSL certificate changes to your virtual host.
Locate the LSWS PID option and click Graceful Restart to restart the server.
Click GO to confirm the restart and apply the configuration changes.
When running multiple virtual hosts on your server. Navigate to the Virtual Hosts tab, open your target virtual host, and click SSL to enable an SSL certificate to bind with the virtual host configuration.
UFW is active by default on Vultr Ubuntu servers. Follow the steps below to configure the firewall to allow access to the OpenLiteSpeed web admin port 7080, HTTPS port 443, and HTTP port 80.
Enable UFW and allow connections to the SSH port 22 if it's inactive on your server.
Allow connections to the OpenLiteSpeed console port 7080.
Allow HTTP connections on the server.
Allow HTTPS connections.
Restart UFW to apply your firewall changes.
View the firewall status and verify that the new rules are active on your server.
Access your virtual host's domain using HTTPS in a new web browser window to test your SSL configurations.
You have installed OpenLiteSpeed on Ubuntu 20.04 and set up a sample virtual host to deliver web applications securely. OpenLiteSpeed supports PHP, enabling dynamic web applications.
0 Comments
Be the first to comment and share your perspective with the community.