There is a new version of this tutorial available for Debian 12 (Bookworm).

How to Install LOMP Stack (OpenLiteSpeed, MariaDB, and PHP) on Debian 11

The LOMP Stack is a popular software suite to deliver web applications. LOMP stands for Linux as the operating system, OpenLiteSpeed as the web server, MySQL/MariaDB as the database server, and PHP for the backend of applications.

The LOMP Stack provides flexibility and efficiency to build and deliver web applications. Also, each component of the LOMP Stack is free and open-source. It's suitable for developers on local development or to deliver applications on server production.

In this tutorial, you will install the LOMP Stack (OpenLiteSpeed, MariaDB, and PHP) on the Debian 11 server. You will also learn how to set up the OpenLiteSpeed web server with PHP 8.x.

Prerequisites

To begin with this guide, you will need some following requirements:

  • One Debian 11 server.
  • A non-root user with sudo root privileges.
  • A domain name pointed to your server IP address.

Installing OpenLiteSpeed

In this first step, you will add the OpenLiteSpeed repository for the Debian system and install the OpenLiteSpeed web server.

The OpenLiteSpeed provides a bash script that allows you to set up the OpenLiteSpeed repository automatically on your system.

Run the following command to download the bash script and add the OpenLiteSpeed repository to your system.

wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash

As you can see in the following screenshot, the script will automatically detect the current operating system and add the OpenLiteSpeed repository and GPG key. And also, the repository is automatically refreshed.

add openmlitespeed repo

Now install the OpenLiteSpeed web server via the apt command below. When prompted to confirm the installation, input y and press ENTER to proceed.

sudo apt install openlitespeed

install openlitespeed

After OpenLiteSpeed is installed, run the following systemctl command below to verify the OpenLiteSpeed service 'lsws' and make sure the service is running.

sudo systemctl is-enabled lsws
sudo systemctl status lsws

You should see in the following screenshot the OpenLiteSpeed service 'lsws' is enabled and will be run automatically at system boot. And the status of the lsws service is running.

check openlitespeed

The default OpenLiteSpeed is running on port 8088. So, open your web browser and visit the server IP address followed by port 8088 (i.e: http://192.168.5.30:8088/) and you will see the default index.html page of the OpenLiteSpeed web server.

openlitespeed index

Installing MariaDB Server

After you have installed the OpenLiteSpeed, you will now install and configure the MariaDB database server as part of the LOMP Stack. The default Debian repository provides the latest stable version of the MariaDB server, which is should be fine for production.

Run the following apt command to install the MariaDB database server. When prompted to confirm the installation, input y and press ENTER to proceed.

sudo apt install mariadb-server

install mariadb

After MariaDB is installed, run the following command to verify the MariaDB service and make sure the service is running.

sudo systemctl is-enabled mariadb
sudo systemctl status mariadb

You will now receive the output like the following. The MariaDB service is enabled and will be run automatically at system boot. And the status of the MariaDB service is running.

check mariadb

At this point, the MariaDB database is running. Now you will be securing the MariaDB deployment via the command line 'mysql_secure_installation', which is provided by the MariaDB package.

Run the following command to start configuring the MariaDB server.

sudo mysql_secure_installation

You will now be asked about some of the MariaDB server configurations:

  • Change the root authentication method to unix_socket? Input n.
  • Change the MariaDB root password? Input Y to confirm, then input the new password for your MariaDB root user.
  • Remove the default database test? Input Y to confirm.
  • Disable the remote login for the root user? Input Y to confirm.
  • Remove the default anonymous user from the installation? Input Y to confirm.
  • Reload tables privileges to apply new changes? Input Y to confirm.

Now the MariaDB server deployment is finished and secured. You can now log in to your MariaDB server securely via the root user.

Installing PHP 8.0

To set up PHP with the OpenLiteSpeed web server, you must install PHP packages provided by the OpenLiteSpeed repository. The default OpenLiteSpeed repository provides multiple versions of PHP, including PHP 7.4, 8.0, and 8.1.

For this step, you will install PHP 8.0 and set it up with OpenLiteSpeed.

Run the following apt command to install PHP 8.0 from the OpenLiteSpeed repository. As you can see, the PHP package name for the OpenLiteSpeed begins with 'lsphp80-package-name'.

sudo apt install lsphp80 lsphp80-common lsphp80-mysql lsphp80-dev lsphp80-curl

When prompted to confirm the installation, input y and press ENTER to proceed to the installation.

install php

Additionally, this will automatically install the PHP 7.4 version from the OpenLiteSpeed repository. The default PHP version of the current OpenLiteSpeed web server is PHP 7.4.

Now after PHP 8.0 is installed, run the following command to ensure that the PHP 8.0 is installed on your system. The PHP installation directory for OpenLiteSpeed is available at the '/usr/local/lsws' directory.

/usr/local/lsws/lsphp80/bin/php8.0 -v

You should receive an output that the PHP 8.0 is installed.

check php

You can also verify by using the following. This will check the default and enabled modules for PHP 8.0.

/usr/local/lsws/lsphp80/bin/php8.0 --modules

Setting up Admin User for OpenLiteSpeed

At this point, the LOMP Stack packages are now installed. Now you will be setting up your LOMP Stack installation.

At first, you will be setting up the administrator user for OpenLiteSpeed.

The OpenLiteSpeed web server provides an interactive administration dashboard that runs on the default port 7080. The OpenLiteSpeed administration dashboard allows you to set up an OpenLiteSpeed web server via a GUI or web browser.

Run the following command to start configuring the OpenLiteSpeed administrator user.

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

You will now be asked to set up the admin user for OpenLiteSpeed. The default user is 'admin', but you can change it with your user.

After that, input the new password for the OpenLiteSpeed web server and repeat. Now the administrator user for OpenLiteSpeed is configured.

setup admin

Next, back to the web browser and visit the server IP address followed by the default admin port 7080 with HTTPS protocol (i.e: https://192.168.5.30:7080/).

You will see the OpenLiteSpeed administrator login page. Input the username and password, then click Login.

opernlitepseed login page

If you are using the correct username and password, you should see the OpenLiteSpeed administration dashboard.

openlitespeed admin dashboard

Running OpenLiteSpeed on HTTP Port 80

The default OpenLiteSpeed is running on port 8088. Now you will change the default HTTP port for the OpenLiteSpeed to port 80 via the OpenLiteSpeed administration dashboard.

Click the 'Listener' menu on the left side and you will see the 'Default' listener that running on port 8088.

list of listener

Click the zoom icon on the 'Action' section to start modifying the 'Default' listener.

Now click the edit button on the top right to modify the 'Default' listener

change listener default

Change the default port to 80 and click the Save button.

change listener to port 80

Next, click the reload button to restart the OpenLiteSpeed web server and apply new changes.

reload openlitespeed

After you click the reload button, you will be prompted for confirmation. So click OK to confirm and then the OpenLiteSpeed will be restarted and you will be redirected to the OpenLiteSpeed login page.

Now open a new tab on your web browser and visit the server IP address with the default HTTP port (i.e: http://192.168.5.30) - You should see the default index.html page of the OpenLiteSpeed web server.

openlitespeed run port 80

Setting up PHP 8.0 with OpenLiteSpeed

At this point, the default OpenLiteSpeed is running with PHP 7.4 automatically installed during the PHP installation. For this step, you will set up the PHP 8.0 with OpenLiteSpeed.

Click on the 'Server Configuration' menu and select the 'External App' tab. And you should get the default external app 'LiteSpeed SAPI App' that runs the default PHP version 7.4.

On the 'Action' section, click the edit button to start modifying the external app.

edit php configuration

On the 'Command' section, change the default PHP version to PHP 8.0 installation 'lsphp80/bin/lsphp'.

The starting point for the PHP binary path is '/usr/local/lsws'. And you can verify the PHP 8.0 for OpenLiteSpeed is installed on the '/usr/local/lsws/lsphp80' directory.

Click the Save button to confirm and save the changes.

setup php 8

Next, click the reload button to restart the OpenLiteSpeed and apply new changes.

reload openlitespeed

Lastly, open a new tab on your web browser and visit the server IP address followed by the path '/phpinfo.php' (i.e: http://192.168.5.30/phpinfo.php).

You will see the PHPINFO page with details of your PHP installation - on top of the page you can see the current PHP version configured with OpenLiteSpeed is PHP 8.0.

lomp stack phpinfo

Conclusion

In this guide, you have installed the LOMP Stack (OpenLiteSpeed, MariaDB, and PHP) on a Debian 11 server. You also have learned how to secure MariaDB deployment and learned the basic configuration of PHP with the OpenLiteSpeed web server.

For the next, you may be interested in how to set up a virtual host on OpenLiteSpeed to deploy multiple PHP web applications or setting up the SSL on OpenLiteSpeed.

Share this page:

0 Comment(s)