
Install OpenLiteSpeed on FreeBSD 14 to leverage a high-performance, open-source webserver designed for low resource consumption. OpenLiteSpeed features an event-driven architecture, built-in caching, and a user-friendly web-based administration interface. It supports modern web technologies, including HTTP/2, HTTP/3, QUIC, and Brotli compression, making it an efficient and powerful solution for hosting dynamic web applications.
This article explains how to install OpenLiteSpeed on FreeBSD 14 and configure the webserver to serve web applications using virtual host configurations.
OpenLiteSpeed is not available in the default package repositories and ports collection on FreeBSD. Follow the steps below to build and install OpenLiteSpeed on a FreeBSD server from source.
Update the server's package index.
Install all required dependencies for building OpenLiteSpeed.
Yet Another JSON Library (YAJL) is a lightweight, and highly portable JSON parsing and generation library written in C. OpenLiteSpeed requires YAJL to install and run dynamic libraries. Follow the steps below to build and install the YAJL dynamic library.
Create the /usr/local/src directory to store your project files.
Switch to the /usr/local/src directory.
Clone the YAJL repository using Git.
Switch to the cloned yajl directory.
Checkout to the latest YAJL stable release using Git. For example, 2.1.0.
Create a new build directory.
Switch to the build directory.
Run the following cmake command to build YAJL as a dynamic library.
Use the make install command to install the YAJL library.
List all files in the /usr/local/lib/libyajl.* directory to verify that YAJL is installed.
Update the system's dynamic linker cache to read shared libraries in the /usr/local/lib directory.
Create a LDFLAGS environment variable to enable OpenLiteSpeed to access all required libraries.
Create a CPPFLAGS environment variable to enable the gcc compiler to access dependency libraries.
If you are using Debian 12, you can follow this guide to install OpenLiteSpeed on Debian 12 and set up a high-performance, lightweight webserver with support for modern web technologies.
Follow the steps below to build and install OpenLiteSpeed on FreeBSD after setting up all necessary libraries including YAJL on the server.
Switch to the /usr/local/src directory.
Clone the OpenLiteSpeed repository.
Switch to the openlitespeed directory.
Checkout to the latest stable release. For example, 1.8.2.
Update all submodules using Git.
Open the /usr/local/src/openlitespeed/src/extensions/cgi/lscgid.cpp file using a text editor such as nano.
Add the following #define LS_NS_LEN 5 preprocessor directive after the *** comments in the file.
Save and close the file.
The above #define LS_NS_LEN 5 preprocessor directive enables the CGI module namespace used for unique process identification tasks. Ensure that the directive includes the # symbol to work correctly on your server. Setting the directive's value to 5 enables compatibility with other system processes and prevents namespace collisions.
Use the ldconfig command to apply the configuration changes.
Run the build.sh script to build OpenLiteSpeed.
Wait for at least 15 minutes for the build process to complete.
Run the install.sh script to install OpenLiteSpeed.
When the installation is successful, note the default administrator password in your output similar to the one below.
Reboot the server to apply all OpenLiteSpeed changes.
Start the OpenLiteSpeed webserver.
Output:
Access port 8088 using your server's IP address in a web browser such as Chrome and verify that the default OpenLiteSpeed page displays.
Stop the OpenLiteSpeed webserver to set it up as a system service.
If you are using Ubuntu Server, install OpenLiteSpeed on Ubuntu 24.04 to configure a lightweight, high-performance webserver with support for HTTP/3 and built-in caching.
Follow the steps below to set up the OpenLiteSpeed webserver as a system service to automatically start on the server.
Create a new /usr/local/etc/rc.d/openlitespeed file.
Add the following configurations to the file.
Save and close the file.
Enable execute permissions on the script.
Open the /etc/rc.conf file.
Add the following directive to the rc.conf file to enable the OpenLiteSpeed service to automatically start at boot.
Start the OpenLiteSpeed system service.
View the OpenLiteSpeed service status and verify that it's running.
OpenLiteSpeed generates a default administrator password during installation and serves the web administration interface on port 7080 using HTTP. Follow the steps below to reset the default administrator password, generated trusted SSL certificates using a domain and configure the packet filter (pf) firewall to secure connections to the OpenLiteSpeed webserver.
Run the admpass.sh script to reset the OpenLiteSpeed administrator password.
Enter a new administrator username or press Enter to use the default admin username.
Enter a strong administrator password when prompted.
Output:
Search the pkg repository to verify the available Certbot Let's Encrypt client package version.
Output:
Install Certbot depending on the available version.
Use Certbot to generate a new Let's Encrypt SSL certificate using your virtual host domain. Replace app.example.com with your actual domain and admin@example.com with your active email address.
Open the /etc/rc.conf file.
Add the following directives at the end of the /etc/rc.conf file.
Save and close the file.
The above configuration enables the packet filter firewall to automatically start at boot with the following options:
pf_enable="YES": Enables the packet filter firewall.pf_rules="/etc/pf.conf": Sets /etc/pf.conf as the active firewall configuration.pflog_enable="YES": Enables firewall logging.View all network interfaces and note the main interface name to use in the firewall configuration.
Output:
vtnet0 is the public network interface name with the IP address 192.0.2.100 based on the above output.
Create the /etc/pf.conf firewall configuration file.
Add the following configurations to the /etc/pf.conf file.
Save and close the file.
The above firewall configuration enables network connections to the following ports on the server:
22: SSH connections port.80: HTTP port.443: HTTPS port.8088: The default OpenLiteSpeed virtual host port.7080: The OpenLiteSpeed web administration port.Test the /etc/pf.conf file for configuration errors.
Start the packet filter firewall.
The above command may temporarily block your active SSH connection. Ensure to reconnect to the server when the firewall starts.
View the firewall status and verify that it's active.
Output:
A virtual host configuration enables OpenLiteSpeed to serve web applications and services using a specific domain or address on your server. Follow the steps below to create a new OpenLiteSpeed virtual host configuration using your domain and serve a custom HTML web application on the server.
Navigate to the OpenLiteSpeed virtual host configurations directory.
Create a new app.example.com virtual host directory.
Create a new html subdirectory in the app.example.com directory to store the web application files.
Grant the lsadm OpenLiteSpeed user ownership privileges to the directory.
Switch to the app.example.com/html directory.
Run the following command to create a new index.html web application file to display a Greetings from Vultr message.
Follow the steps below to set up the virtual host information using the OpenLiteSpeed web administration dashboard.
Access port 7080 using your server's IP address to log in to the OpenLiteSpeed web administration dashboard.
Enter the OpenLiteSpeed administrator credentials you created earlier to log in.
Click Virtual Hosts in the OpenLiteSpeed dashboard.
Click + within the Virtual Host List section to set up a new virtual host.
Add the following virtual host information to the respective fields.
app.example.com$SERVER_ROOT/conf/vhosts/app.example.com/conf/vhosts/app.example.com/vhconf.confYesYesYesServer UID
Click Save and click the CLICK TO CREATE option when prompted to create the virtual host configuration.
Click Save to apply the virtual host configuration changes.
Click the virtual host to open its management page.
Navigate to the General tab and modify the virtual host configuration with the following information.
$VH_ROOT/html/app.example.comapp.example.comYesYes
Click Save to apply the virtual host changes.
Click Listeners on the main navigation menu.
Click + to set up a new listener with the following details:
app.example.comAny IPv480No
Click Save to apply the listener configuration.
Scroll to the Virtual Host Mappings section and click + to create a new configuration map.
Enter the following details to map the listener to a virtual host configuration.
app.example.comapp.example.com
Click Save to apply the listener configuration.
Follow the steps below to enable secure HTTPS connections to the virtual host using the Let's Encrypt SSL certificates you generated earlier.
Navigate to Listeners page and create a new listener with the following information:
app.example.com.httpsANYIPv4443Yes
Navigate to the Virtual Host Mappings section and map your virtual host configuration with the following details:
app.example.comapp.example.com
Click Save to apply the listener configuration.
Open the listener's configuration page and navigate to the SSL tab.
Enter the following Let's Encrypt SSL certificate paths to apply to your virtual host domain configuration.
/usr/local/etc/letsencrypt/live/app.example.com/privkey.pem/usr/local/etc/letsencrypt/live/app.example.com/fullchain.pemYes
Click Save to apply the virtual host listener configuration changes.
Access your app.example.com virtual host domain in a new web browser window and verify that the Greetings from Vultr prompt displays.
You have installed OpenLiteSpeed on FreeBSD 14 from source code and enabled the webserver to automatically start at boot. You can create multiple virtual host configurations and listeners to deliver web applications on the server. For more webserver configuration options, please visit the OpenLiteSpeed documentation.
0 Comments
Be the first to comment and share your perspective with the community.