Install Drupal on Ubuntu 16.04 LTS with OpenLiteSpeed, MariaDB and PHP 7.1 Support

When you look at the web hosting landscape, you’ll see majority of the sites hosted on Apache2 or Nginx HTTP servers.. However, few people know about OpenLiteSpeed or Lighttpd HTTP servers and the performance benefits they provide…

This brief tutorial shows students and new users how to install Drupal on Ubuntu 16.04 LTS with OpenLiteSpeed, MariaDB and PHP 7.1 support. If you haven’t heard of OpenLiteSpeed, is an open source web server developed by LiteSpeed Technology. It’s designed to be lightweight with a user friendly web interface to create and manage your websites.

You will learn how to install OpenLiteSpeed with MariaDB and PHP 7.1… and how to configure OpenLiteSpeed to allow Drupal to work. When you’re ready, continue with the steps below:

Step 1: Update the Ubuntu

It’s always good to update Ubuntu server prior to installing new packages… to update Ubuntu, 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 zlib1g-dev libssl-dev libxml2-dev rcs libpng-dev

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.27 to your server..

cd /tmp/ && wget http://open.litespeedtech.com/packages/openlitespeed-1.4.27.tgz

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

tar -xvzf openlitespeed-1.4.27.tgz

Change into the directory extracted directory

cd openlitespeed-1.4.27/

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]: openlite

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://example.com:8088

To access the admin backend portal, use the port 7078

https://example.com:7080

openlitespeed ubuntu

Step 5: Install MariaDB Database Server

To install MariaDB server run the commands below.

sudo apt-get install mariadb-server mariadb-client

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

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

After that, run the commands below to secure MariaDB server.

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

sudo systemctl restart mysql.service

Step 6: Create Drupal Database

Drupal needs a database… to create one, continue below..

Run the commands below to logon to the database server. When prompted for a password, type the root password you created above.

sudo mysql -u root -p

Then create a blank database called drupaldb  you can use the same database name from the old server.

CREATE DATABASE drupaldb;

Create a database user called drupaluser with new password.  You can use the same username and password from the old server.

CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'type_password_here';

Then grant the user full access to the database.

GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'type_user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 7: Install PHP and Modules

PHP is required to allow Drupal 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

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/lsphp7

Step 8: Install Drupal

Now that OpenLiteSpeed is up, go and download Drupal content. To do that, run the commands below… you will download, extract and copy Drupal content to OpenLiteSpeed default document root.. The default Virtual Host Root is at /usr/local/lsws/Example

Next, visit Drupal site and download the latest package…. or run the commands below to download and extract Drupal content.

After downloading, run the commands below to extract the downloaded file and move it into a new Drupal root directory.

cd /tmp && cd /tmp && wget https://ftp.drupal.org/files/projects/drupal-8.4.2.tar.gz
tar -zxvf drupal*.gz
sudo mv drupal-8.4.2 /usr/local/lsws/Example/drupal

Then run the commands below to set the correct permissions for Drupal to function properly.

sudo chown -R nobody:nogroup /usr/local/lsws/Example/drupal/
sudo chmod -R 755 /usr/local/lsws/Example/drupal/

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

https://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/lsphp7

openlitespeed wordpress

Next, go to Virtual Hosts ==> View to edit the current VirtualHost settings..

When the settings page opens, click the General tab and edit the Document Root location.. to where we installed our Drupal content in the drupal folder…

$VH_ROOT/drupal/

On the same General tab, edit the Index File section and replace index.html with index.php shown below…. save the exit.

openlitespeed wordpress

Next, go to Virtual Hosts ==>  Rewrite and edit it… then turn on Rewrite Control to Yes

wordpress ubuntu openlitespeed

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

ReWriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^/ index.php [L]
<IfModule LiteSpeed>
CacheLookup on
</IfModule>

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

If you can’t get Drupal default page show, go to Virtual Hosts ==> Context… then delete the /protected/ URL in the list below.. Restart the server and try again..

openlite speed wordpress

After restarting, open your browser and browse to the server hostname or IP address and you should see Drupal setup wizard.

http://example.com

varnish drupal ubuntu

Continue with the wizard until you’ve successfully configure Drupal.

If you get a server error: “SQLSTATE[HY000] [2002] No such file or directory”, use IP 127.0.0.1 instead of hostname under advanced and continue…

Enjoy!

You may also like the post below:

Install Webmin / Virtualmin on Ubuntu 16.04 LTS Server