Install OpenLiteSpeed on Ubuntu 16.04 | 18.04 with MariaDB and PHP 7.1 / PHP 7.2

OpenLiteSpeed, is an open source web server developed by LiteSpeed Technology… An open source source edition of LiteSpeed Web Server Enterprise….

OpenLiteSpeed is designed to be lightweight with a user friendly web interface to help webmasters create and manage their websites easily… New users and students should find this web server to be useful and convenient…

When it comes to webservers, most have heard about Apache2, Nginx and other less popular ones… however, OpenLiteSpeed should be at the top because it combines speed, security, scalability, optimization and simplicity in one friendly web interface…

This brief tutorial shows students and new users how to install OpenLiteSpeed with MariaDB and PHP 7.1 or PHP 7.2 support.

Step 1: Update the Ubuntu Server

Before installing OpenLiteSpeed and the other applications, please update Ubuntu server. To do that, run the commands below.

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove

Step 2: Install OpenLiteSpeed Dependencies

After updating the server, install the packages below to install required dependencies for OpenLiteSpeed.

sudo apt install build-essential libexpat1-dev libgeoip-dev libpcre3-dev libudns-dev zlib1g-dev libssl-dev libxml2 libxml2-dev rcs libpng-dev libpng-dev openssl

Step 3: Download and Install OpenLiteSpeed

Now that all dependencies are installed, go and fetch the latest version of OpenLiteSpeed. The commands below will download version 1.4.34 to your server..

cd /tmp/ && wget https://openlitespeed.org/packages/openlitespeed-1.4.34.tgz

Next, run the commands below to extract the downloaded package.

tar -xvzf openlitespeed-1.4.34.tgz

Change into the directory extracted directory

cd openlitespeed-1.4.34/

Then run the commands below to install OpenLiteSpeed.

sudo ./configure
sudo make
sudo make install

After that OpenLiteSpeed should be installed and ready to use.

Step 4: Configure OpenLiteSpeed

Finally, configure the administrative password for the web interface. Run the commands below to do that.

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

Then create a web admin username and password.

Please specify the user name of administrator.
This is the user name required to login the administration Web interface.

User name [admin]: openliteadmin

Please specify the administrator's password.
This is the password required to login the administration Web interface.

Password: new_password
Retype password: retype_password
Administrator's username/password is updated successfully!

After that, run the commands below to start the webserver.

sudo /etc/init.d/lsws start

Open your browser and browse to the server IP or hostname followed by 8088 to view the default page page.

http://localhost:8088

To access the admin backend portal, use the port 7078

https://192.168.1.2:7080

openlitespeed ubuntu

Step 5: Install MariaDB Database Server

MariaDB database server is a great place to start when looking at open source database servers to use with OpenLiteSpeed… To install MariaDB run the commands below…

sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots..

Run these on Ubuntu 16.04 LTS

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Run these on Ubuntu 18.04 and 18.10 LTS

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

To test if MariaDB is installed, type the commands below to logon to MariaDB server

sudo mysql -u root -p

Then type the password you created above to sign on… if successful, you should see MariaDB welcome message

mariadb welcome

Step 6: Install PHP 7.1 and Modules

PHP is required to allow PHP apps to function….. run the commands below to add OpenLiteSpeed repository to your system…

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

After adding the repository,  run the commands PHP 7.1 and related modules..

sudo apt install lsphp71 lsphp71-common lsphp71-mysql lsphp71-tidy lsphp71-recode lsphp71-recode lsphp71-opcache

To install PHP 7.2 and related packages, run the commands below:

sudo apt install lsphp72 lsphp72-common lsphp72-mysql lsphp72-tidy lsphp72-recode lsphp72-recode lsphp72-opcache

Next, run the commands below to create a symbolic link for PHP 7.1

sudo ln -sf /usr/local/lsws/lsphp71/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp71

For use PHP 7.2, run the commands below…

sudo ln -sf /usr/local/lsws/lsphp72/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp72

After that, open your browser and browse to OpenLiteSpeed backend portal..

http://example.com:7080

Go to the Dashboard and select Server Configuration ==> External App…  then click Edit as shown in the image below…

openlitespeed wordpress

Then scroll to Command, then change the command to reflect the symbolic link created above for PHP 7.1 and save.

$SERVER_ROOT/fcgi-bin/lsphp71

For PHP 7.2, use the line below:

$SERVER_ROOT/fcgi-bin/lsphp72

openlitespeed wordpress

Next, go to Virtual Hosts ==> General page…. and click edit of the Index File section and add index.php to the list as shown below.

openlitespeed wordpress ubuntu

Next, select the Rewrite tab and turn on Rewrite Control

wordpress ubuntu openlitespeed

Next edit the Rweire Rules and replace the code with the one below, then save..

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

openlistspeed

Save and continue.

Finally, click on the Listeners from the left menu, then edit to change the current port from 8088 to 80. Save after that.

openlitespeed wordpress

Go to the Dashboard and restart the server from the top right corner…

To validate whether PHP is working, open the URL below…

http://localhost/phpinfo.php

ubuntu php apache2

After restarting, open your browser and browse to the server hostname or IP address and you should see your PHP app…..

http://localhost/

All you have to do now is put your PHP app in the default root directory:

/usr/local/lsws/Example/html

Enjoy!

You may also like the post below:

Setup Mautic on Ubuntu 16.04 / 18.04 with Nginx, MariaDB and PHP 7.1-FPM

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.