Ubuntu 22.04 how to install linux openlitespeed mariadb php lomp stack on ubuntu 22-04

October 2, 2022 . 2 MIN READ

Before starting, ensure you have:

  • An Ubuntu 22.04 server with a non-root sudo user.

  • A Domain Name pointed to your server’s IP.

  • SSL Certificates (obtained via Certbot) located in /etc/letsencrypt/live/your_domain/.


Step 1 — Installing OpenLiteSpeed

OpenLiteSpeed maintains its own repository. To install it, you must add their software source to your system.

  1. Update and Upgrade:

    Bash

    sudo apt update && sudo apt upgrade -y
    
  2. Add OpenLiteSpeed Repository:

    Bash

    sudo wget -O - https://repo.litespeed.sh | sudo bash
    
  3. Install the Server:

    Bash

    sudo apt update
    sudo apt install openlitespeed
    
  4. Verify Service:

    Bash

    sudo systemctl status lsws
    

Step 2 — Configuring the Firewall

OpenLiteSpeed uses specific ports for its admin panel and example site. You need to open these in ufw.

  • 7080: Admin Panel

  • 8088: Example Website

  • 80/443: Standard HTTP/HTTPS

Bash

sudo ufw allow 7080,80,443,8088/tcp

Step 3 — Installing MariaDB

MariaDB handles the database layer of your stack.

  1. Install MariaDB:

    Bash

    sudo apt install mariadb-server
    
  2. Secure the Installation: Run sudo mysql_secure_installation.

    • Switch to unix_socket authentication: Y

    • Set root password: Y

    • Remove anonymous users: Y

    • Disallow root login remotely: Y

    • Remove test database: Y

    • Reload privilege tables: Y


Step 4 — Installing PHP (LSPHP)

OpenLiteSpeed uses LSPHP to process dynamic content faster via the LSAPI.

  1. Search for versions: sudo apt-cache search lsphp

  2. Install PHP 8.1:

    Bash

    sudo apt install lsphp81 lsphp81-common lsphp81-mysql
    

Step 5 — Configuring the OpenLiteSpeed Admin Panel

To manage the server via the web interface, set your administrative credentials first.

  1. Set Admin Password:

    Bash

    sudo /usr/local/lsws/admin/misc/admpass.sh
    
  2. Access the Panel: Navigate to http://your_server_ip:7080.

  3. Set PHP Version: * Go to Server Configuration > External App.

    • Edit the lsphp app and change the Command to lsphp81/bin/lsphp.

    • Perform a Graceful Restart (top right icon).


Step 6 — Setting Up a Virtual Host & SSL

Virtual Hosts allow you to host specific domains.

  1. Create Virtual Host: In the Admin Panel, add a new Virtual Host.

    • Name: MyWebsite

    • Root: $SERVER_ROOT/MyWebsite/html/

    • Config File: conf/vhosts/MyWebsite/vhconf.conf (Click “click to create” if prompted).

  2. Map Listener:

    • Navigate to Listeners > Default.

    • Under Virtual Host Mappings, add your domain and map it to MyWebsite.

  3. Configure SSL:

    • Change the Listener port to 443 and set Secure to Yes.

    • Under the SSL tab, provide the paths to your Let’s Encrypt keys:

      • Private Key: /etc/letsencrypt/live/your_domain/privkey.pem

      • Certificate: /etc/letsencrypt/live/your_domain/fullchain.pem

      • Chained Certificate: Yes

  4. Enable HTTP/3 (QUIC): OpenLiteSpeed supports HTTP/3 out of the box. Simply allow UDP traffic on the firewall:

    Bash

    sudo ufw allow 443/udp
    

Conclusion

Your LOMP stack is now operational. You have a Linux environment running OpenLiteSpeed with a secured MariaDB database and optimized PHP 8.1. You can now begin uploading your WordPress or Laravel files to the Virtual Host root directory.

Next Step: Would you like me to generate a technical diagram showing how the LiteSpeed SAPI (LSAPI) handles PHP requests compared to standard FastCGI?

Reference:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-openlitespeed-mariadb-php-lomp-stack-on-ubuntu-22-04

Leave a Reply

Your email address will not be published. Required fields are marked *