How to Install and Configure OpenLiteSpeed Web Server on Ubuntu 22.04 LTS

Setting up a reliable and high-performance web server is essential for hosting applications and websites efficiently. OpenLiteSpeed is an open-source web server that provides excellent performance, scalability, and a range of features to meet various project needs, from small websites to large-scale applications. This guide will walk you through the process of installing and configuring OpenLiteSpeed Web Server on Ubuntu 22.04 LTS.

Prerequisites

Before getting started, make sure you have:

  • Administrative access to the server.
  • A basic understanding of Linux command-line interfaces and web server configurations.

Technical Implementation

Step 1: Update and Install Dependencies

Start by updating the system package list and installing the required dependencies:

# Update the system package list and install essential dependencies
sudo apt update && sudo apt install -y build-essential libpcre3-dev zlib1g-dev libssl-dev libxml2-dev libxslt-dev git

Step 2: Install OpenLiteSpeed from Official Repository

Add the OpenLiteSpeed repository to your system and install it:

# Add the OpenLiteSpeed repository
wget -O - https://repo.litespeed.sh | sudo bash

# Install OpenLiteSpeed
sudo apt install openlitespeed -y

Step 3: Start and Enable OpenLiteSpeed Service

Start OpenLiteSpeed and enable it to start on boot:

# Start OpenLiteSpeed
sudo systemctl start lsws

# Enable OpenLiteSpeed to run at boot
sudo systemctl enable lsws

Step 4: Access the OpenLiteSpeed Admin Panel

The OpenLiteSpeed admin panel runs on port 7080 by default. To access it:

  1. Open your web browser and go to http://<your-server-ip>:7080.
  2. Log in using the default credentials:
  • Username: admin
  • Password: 123456

For security, change the default password:

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

Step 5: Configure Your Website

To configure your website, follow these steps:

  1. Log in to the OpenLiteSpeed WebAdmin panel.
  2. Navigate to Listeners > Default.
  3. Add a virtual host:
  • Virtual Host Name: Choose a name (e.g., mydomain).
  • Virtual Host Root: /usr/local/lsws/your-domain
  1. Map the virtual host to your listener under Listeners.

Step 6: Set Up PHP

OpenLiteSpeed comes with LSPHP (LiteSpeed PHP), which integrates seamlessly:

# Install LSPHP for PHP 8.1
sudo apt install lsphp81 lsphp81-common lsphp81-mysql lsphp81-curl -y

Configure the web server to use LSPHP:

  1. Navigate to Server Configuration > External App.
  2. Add a new External App with:
  • Name: lsphp
  • Address: uds://tmp/lsphp.sock
  • Command: /usr/local/lsws/lsphp81/bin/lsphp
  1. Map the Script Handler to PHP under Script Handler settings.

Step 7: Enable SSL/TLS for Secure Connections

For secure web traffic, configure SSL/TLS:

  1. Navigate to Listeners and select your listener.
  2. Under SSL, enable Secure and add your certificate and private key paths.
  3. Save the configuration and restart OpenLiteSpeed:
   sudo systemctl restart lsws

Best Practices

  • Keep OpenLiteSpeed Updated:
    Regularly update OpenLiteSpeed to ensure access to the latest features and security patches.
  • Use a Reverse Proxy:
    Utilize NGINX or Apache as a reverse proxy for load balancing and additional features.
  • Implement Monitoring:
    Integrate monitoring tools to track server performance and logs for early detection of issues.
  • Enforce Security:
    Configure strong SSL/TLS encryption and use a web application firewall (WAF) to protect against vulnerabilities.

Troubleshooting

Common Issues and Solutions

  • Configuration Errors:
    Check the OpenLiteSpeed log files located in /usr/local/lsws/logs/error.log for detailed error messages.
  • Access Denied:
    Ensure that your firewall allows traffic on the required ports:
  sudo ufw allow 80/tcp
  sudo ufw allow 443/tcp
  sudo ufw allow 7080/tcp
  • Slow Performance:
    Optimize the number of worker processes and adjust cache settings in the WebAdmin panel.

Conclusion

In this guide, you’ve learned how to install and configure OpenLiteSpeed Web Server on Ubuntu 22.04 LTS. By following these steps, you now have a powerful, scalable, and secure web server setup. Regularly monitor your server, apply best practices, and integrate additional tools to maximize performance and security.

Next Steps

  • Integrate OpenLiteSpeed with Docker for containerized deployments.
  • Incorporate CI/CD Pipelines using Jenkins or GitLab CI/CD to streamline deployment processes.
  • Explore Caching Solutions such as LiteSpeed Cache for enhanced performance.

Leverage your newly set up OpenLiteSpeed server for hosting high-performance, scalable web applications efficiently.