Install OpenLiteSpeed on Ubuntu 16.04 LTS with MariaDB and PHP Support

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 easily… New webmasters who are managing their own websites should find this web server to be useful and convenient…

When it comes to WordPress, you’ll find countless tutorials on how to install it on Apache2 or Nginx or other web servers… this post shows you an alternative to those two web servers… You will learn how to install OpenLiteSpeed, MariaDB and PHP.. then shows you how to configure OpenLiteSpeed to make WordPress function.

This brief tutorial shows students and new users how to install WordPress on Ubuntu 16.04 LTS with OpenLiteSpeed, MariaDB and PHP support.

When you’re ready, continue with the steps below:

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 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://192.168.1.2:8088

To access the admin backend portal, use the port 7078

https://192.168.1.2:7080

openlitespeed ubuntu

Step 5: Install MariaDB 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 WordPress Database

WordPress 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 WP_database  you can use the same database name from the old server.

CREATE DATABASE WP_database;

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

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

Then grant the user full access to the database.

GRANT ALL ON WP_database.* TO 'wp_user'@'localhost' IDENTIFIED BY 'type_user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Step 7: Install WordPress

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

cd /tmp && wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
sudo mv wordpress /usr/local/lsws/Example/wordpress

Then run the commands below to set the correct permissions for WordPress root directory.

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

STEP 8: CONFIGURE WORDPRESS

Next, run the commands below to create WordPress wp-config.php file. This is the default configuration file for WordPress.

sudo mv /usr/local/lsws/Example/wordpress/wp-config-sample.php /usr/local/lsws/Example/wordpress/wp-config.php

Then run the commands below to open WordPress configuration file.

sudo nano /usr/local/lsws/Example/wordpress/wp-config.php

Enter the highlighted text below that you created for your database and save.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'WP_database');

/** MySQL database username */
define('DB_USER', 'wp_user');

/** MySQL database password */
define('DB_PASSWORD', 'new_password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Save the file and you’re done.

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

http://example.com:7080

Then go to Virtual Hosts on the left menu to bring up the virtualhost settings page.. then click the view button to view its settings..

When the settings page opens, click the General tab and edit the Document Root location.. we’ll want to change this to our WordPress folder.

openlite wordpress ubuntu

On the same General tab, edit 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

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

http://example.com

ubuntu wordpress lets encrypt

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

Enjoy!

You may also like the post below:

Setup Apache2 HTTP/2 with Let’s Encrypt free SSL/TLS Certificates on Ubuntu 16.04 LTS Server

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.