How to Install OpenLiteSpeed with PHP on Ubuntu

How to Install OpenLiteSpeed and PHP on Ubuntu

In this tutorial, I will guide you step-by-step through the installation and configuration of OpenLiteSpeed and PHP on Ubuntu.

OpenLiteSpeed ​​is a free open-source lightweight HTTP server developed by LiteSpeed ​​Technologies. It is a powerful, modular HTTP server and can handle hundreds of thousands of simultaneous connections with low resource usage. OpenLiteSpeed offers unbeatable performance, security, scalability, simplicity, and optimization all bundled in a single package.

OpenLiteSpeed provides a web-based user interface for managing the web server through a web browser. It uses the same configuration as the Apache web server and is compatible with most features offered by Apache.

1. Upgrade the Current Ubuntu System

Before running the tutorial below, it’s important to make sure your Ubuntu system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Related: How to Use apt Command to Manage Packages in Linux

2. Add the OpenLiteSpeed Repository

OpenLiteSpeed provides a software repository we can use to download and install the server. But first, we need to add it to our Ubuntu system because it is not included in the Ubuntu default repositories.

So we will use the official script provided by OpenLiteSpeed to automatically add the correct repository to our Ubuntu system. 

wget -O - | sudo bash
Adding OpenLiteSpeed Repository

3. Install OpenLiteSpeed Web Server

Once the repository is added, the OpenLiteSpeed server is available for install using the command below:

sudo apt install openlitespeed

Next, verify the status of the OpenLiteSpeed service with the following command:

sudo systemctl status lshttpd
Checking OpenLiteSpeed Service Status

4. Install PHP 8 for OpenLiteSpeed

When we install OpenLiteSpeed it automatically installs PHP 7.3 build made for OpenLiteSpeed. We can install PHP 8.0 with the following command:

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

Once all the packages are installed, you can proceed to the next step. If you wish to install a different version of PHP just replace lsphp80 with lsphp74, for example.

5. Setup OpenLiteSpeed Admin Password

OpenLiteSpeed provides a web console that listens by default on port 7080. You’ll need to set an admin username and password to access it. 

After running the below command you will be prompted to input the admin username and password. Pressing Enter without choosing a new username defaults to admin as the new administrative username. The username input is followed by a password. Retype the password and hit enter.

sudo /usr/local/lsws/admin/misc/
Set an Administration Username and Password

6. Access OpenLiteSpeed Admin Console

Point your browser to http://your-server-ip:7080 and you should get a login page as shown below. Provide your admin username and password and click on the “Login” button. 

Admin Web Console Login

You’ll then be greeted by the OpenLiteSpeed dashboard view.

OpenLiteSpeed Admin Web Console

This is where the majority of your configuration for the web server will take place.

7. Configure PHP 8 for OpenLiteSpeed

Next, click the “Server Configuration” menu on the left and click the “External App” tab. To add the new PHP 8 configuration, click the add “+” button on the right.

Configure PHP 8

For the type, choose the “LiteSpeed SAPI App” and click the “Next” button.

Configure PHP 8

Provide the following information:

  1. Name: lsphp80
  2. Address: uds://tmp/lshttpd/lsphp.sock
  3. Max Connections: 100
  4. Initial Request Timeout (secs): 60
  5. Retry Timeout (secs): 0
  6. Command: lsphp80/bin/lsphp

Next, click on the “Save” button to save the configuration.

Configure PHP 8

You should see the following page.

Configure PHP 8

Now you need to change the default PHP for OpenLiteSpeed to the PHP 8.0 version. Click on the “Script Handler” tab and then hit the “Edit” button. 

Configure PHP 8

Select lsphp80 from the dropdown menu in the “Handler Name” and click on the “Save” button.

Configure PHP 8

You should see the following page.

Configure PHP 8

8. Change OpenLiteSpeed Default Port

By default, OpenLiteSpeed listens on port 8088. We can change it to use port 80 instead which is the default port for HTTP requests.

To do this, click “Listeners” in the list of options on the left side of the interface. Then on the right under “Actions“, click on the “View” icon.

Change the OpenLiteSpeed Default Port from 8088 to 80

This will load a page with more details about the default listener. Click the “Edit” icon on the Address Settings.

Change the OpenLiteSpeed Default Port from 8088 to 80

In the default listener address settings, change the port from 8088 to 80 and click on the “Save” (floppy disk) icon to save the settings.

Change the OpenLiteSpeed Default Port from 8088 to 80

Next, click on the “Restart” icon and perform the graceful restart to apply the changes.

Change the OpenLiteSpeed Default Port from 8088 to 80

When prompted, hit the “Go” button.

Change the OpenLiteSpeed Default Port from 8088 to 80

Now, you can access your OpenLiteSpeed web server using the URL http://your-server-ip.

OpenLiteSpeed Web Server Default Web Page

You can also enter http://your-server-ip/phpinfo.php in the browser to test PHP 8 with OpenLiteSpeed Web server. As a result, you should get the phpinfo page as below.

PHP 8.0 Installed and Configured Successfully in OpenLiteSpeed on Ubuntu


Congratulations! At this point, you should have OpenLiteSpeed and PHP 8 installed and running on an Ubuntu. I hope this tutorial helped you.

There is so much that OpenLiteSpeed webserver can do. For more about OpenLiteSpeed, you can refer to the official documentation.

As always, feel free to share your thoughts in the comments box below.

Leave a Reply