How to Install WordPress with OpenLiteSpeed

Do you know How to Install WordPress with OpenLiteSpeed?

OpenLiteSpeed is a high performant web-server especially for WordPress sites because of LSCache plugin.

A great deal of people are opting for OpenLiteSpeed stack to power and speed up their WordPress site, in this article we will see how you can do exactly that.

Install OpenLiteSpeed:

First of all, we have to know how to install OpenLiteSpeed. To do so we are going to mention all the installation steps here. OpenLiteSpeed installation is very easy. Installation for different Operating systems is different but I will add here installation for Centos and Ubuntu.

Here in this article, we will install OLS from CentOs repositories. The difference in the installation process is just the commands steps and the sequence of steps remains the same throughout the process.

  1. You have to add the repositories in order to install OpenLiteSpeed. Here the commands to add repositories to the centos and Ubuntu.

Centos:

rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm

Ubuntu:

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

Adding repository is the first step to install OpenLiteSpeed.

2. After adding repositories to the machine now its time to install OpenLiteSpeed. OpenLiteSpeed is just one command install. Here is the Command.

Centos:

yum install openlitespeed

Ubuntu:

apt-get install openlitespeed

By default, this command installs the latest stable version of the OLS. if you want to install any specific version then the command will be

yum install openlitespeed-x.x.x

Replace x.x.x with any version you are required like 1.2.2 or any you need to install. Once OLS has been installed successfully. You OpenLiteSpeed directory is /usr/local/lsws.

3. To start OpenLiteSpeed server use the command

/usr/local/lsws/bin/lswsctrl start

4. To stop OpenLiteSpeed server use the command

/usr/local/lsws/bin/lswsctrl stop
image 35

Configuring OpenLiteSpeed:

In order to set up WordPress on the LiteSpeed server, you have to do some configurations on your server.

For the configuration, we have to access the LiteSpeed Web Server to access the webserver. You can use the port 7080 with your IP address. You can reach the webserver from the following link https://<your_server_ip>:7080. Once you reach this you can see this screen

OpenLiteSpeed

Provide credentials to log in to the webserver. Usually username=”admin” and if you don’t know the password you can change it by running this simple command

/usr/local/lsws/admin/misc/admpass.sh
image 17

After providing the details you can see the dashboard of LightSpeed Web Server.

image 18

Now it time to do some configurations on the webserver. First of all, from this OpenLiteSpeed dashboard find Server configuration on the menu.

image 19

Go to the External App section present in the Server configuration. And you see LightSpeed SAPI App click Edit.

image 20

After getting to the next page by clicking the Edit button. Now you have to do some configuration according to the PHP version that you have. This is important because OpenLiteSpeed installation won’t be able to correctly execute PHP Scripts. So we have 7.3 We will do configurations according to our version. By default there is lsphp but we have to make it lsphp73. 73 is for my PHP version you can do it for your own version.

We have to correct three things Name, Address and Command according to our version.

image 21

Once you edit these go and save these settings.

Now its time to edits some Virtual Hosts settings. To do so go to the Virtual Hosts section from the left menu.

image 22

You can see an Example Virtual host on the screen view this for some configurations.

image 23

In the Example virtual Host go to the General Tab. And click the edit button. These are some Configurations that are important for WordPress.

image 24

In order to install and setup WordPress, we are going to create a directory WordPress in the next steps so in Document Root we add this. OpenLiteSpeed looks at the contents of the Document Root field for content to serve.

image 42

Once you done click save.

In LightSpeed by default, there is only index.html file as index file but for WordPress, we will need index.php also because its core file for WordPress and This will allow the main logic of WordPress to function correctly.

To do so in General tab go to the index files and click to the edit.

image 26

Add the index.php file also in index file with index.html. and save

image 27

Now we have to do some setting on rewrite rules for this go to the Rewrite tab in the Virtual Host window.

image 28

In Rewrite Enable Rewrite and Auto Load from .htaccess. Make these option yes. And click to save.

image 29

Now we are going to take a look on some security options. As OprnLiteSpeed installation includes some Password protected areas for the authentication features. And we know that WordPress uses its own authentication mechanisms and we will not going to use file-based authentication by Openlitespeed. So we have to remove these so WordPress works properly on its own.

To do so got to the Security tab in the Virtual Hosts option.

image 30

At the end of this screen, you can see a Realm List which has a SampleProtectedArea. Click on the Delete button to remove it.

image 32

It will ask you for confirmation click the Delete button and go on.

Now you have to delete the protectd from context. Go to the Context tab. Here you find /protected/ click delete and delete it.

image 33

Once all done now its time for  Graceful Restart in order to configure all changes we made. To do so click the restart button on the top of screen.

image 34

Now your OpenLiteSpeed is fully configured and good to go.

Installing MySQL

As we know that WordPress uses MySQL. WordPress needs MySQL to store and manage its data. So in order to install WordPress On OpenLiteSpeed, we must have the MySQL installed on the server. Go to the terminal and check the installation of MySQL to check this type of command

mysql -v

This will show you the version of MySQL. If MySQL is not installed there then it will give you MySQL command not found. You have to follow the process.

  1. Download and add the repository
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

2. Install MySQL as usual.

sudo yum install mysql-server

3. Start the service

systemctl start mysqld

Now you have to log in to the MySQL root account. to login to the root access type the command:

sudo mysql
image 36

Now we are going to create a database using this command:

CREATE DATABASE webssite DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

The name of the database is whatever you want to use but here we used “website”. Now we have to create a user how has all rights for this database. You can specify a username and password according to your choice.

GRANT ALL PRIVILEGES ON webssite.* TO 'user'@'localhost' IDENTIFIED BY 'password'; 

Now FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes.

FLUSH PRIVILEGES;

Now exit from mysql.

exit;
image 37

Installing PHP Extensions:

We need to install different PHP extensions and modules in order to run and fulfill the required result for our WordPress Site. Here we mention some of the modules and will install them for PHP 7.3 Installation is the same for every PHP version jus the change of version in command.

Centos:

yum install lsphp73-common lsphp73-curl lsphp73-imagick lsphp73-imap lsphp73-json lsphp73-memcached lsphp73-mysql lsphp73-opcache lsphp73-redis

Ubuntu:

apt install lsphp73-common lsphp73-curl lsphp73-imagick lsphp73-imap lsphp73-json lsphp73-memcached lsphp73-mysql lsphp73-opcache lsphp73-redis

LiteSpeed Repository installs PHP unber /usr/local/lsws/lsphpxx

These are some extensions like redis, mysql, imagick, etc you can also install any other if you wan to.

image 38

Installing and Configuring WordPress:

Now we have to discuss the installation and configuration process of WordPress with the OpenLiteSpeed. We are done with Server configuration and now we are on the installation. You can download the latest version of WordPress from the there official site. You can download WordPress and any directory. I created a directory “mywebsite“. Create the directory using the following command:

mkdir mywebsite
image 39

Go to that specific directory that you created to download WordPress. Use the command cd “your_directory”.

Now its time to download WordPress. You can do it using a command and the command is stated here:

curl -O https://wordpress.org/latest.tar.gz

If you want to download any specific version. Go and get the proper link for that proper version. Now extract the compressed file that you downloaded.

tar xzvf latest.tar.gz

Now your directory look like this:

image 40

Now for the OpenLiteSpeed we have to create a file before going to further process. OpenLiteSpeed Support .htaccess files. this is so important for us to create this file to go for the next steps because WordPress managed and create permalinks using this file. for this purpose, we will use touch command. Here is the whole command to create the .htaccess.

touch /root/mywebsite/wordpress/.htaccess

You can add the path where your WordPress is on the server.

One more important file for the WordPress Installation is the wp-config.php file. All the configuration of WordPress depends upon this file. Whenever we download this file from there official website this there will be a sample file like wp-config-sample.php. for this setup, we are going to copy that sample file into the wp-config .php file to use it. And will configure it. We are going to do it using a command you can do to with any other method too.

 cp /root/mywebsite/wordpress/wp-config-sample.php /root/mywebsite/wordpress/wp-config.php

You can see we have .htaccess and also wp-config.php on our server now.

image 41

For the safe side, we are going to create an upgraded directory so WordPress will not run into permission issues while updating. A very simple command is used for this:

mkdir /root/mywebsite/wordpress/wp-content/upgrade

Always check you changes that you made. Now its time to move the WordPress content to the place from where we can access this. As you remember that we added the path for our WordPress site in the OpenLiteSpeed in the virtual host-> Example -> root document.

We have to move this in /usr/local/lsws/Example/html/mywordpresssite

Now here I mention the command to move my WordPress content to that specific.

cp -a /root/mywebsite/wordpress/. /usr/local/lsws/Example/html/mywordpresssite

This is the command for specific my setup. And also note the “.” in the command. This will copy all the hidden files also.

Now its time to do some critical configuration for your WordPress to be working. We have to do some permission configurations and wp-config.php configuration the most important. First of all, we will go for the permissions of files. We are going to set nobody user and nogroup to the group. OpenLiteSpeed web server runs these as default and gives the ability to read and write these.

Use these command to do so. incase of centos this one will work:

sudo chown -R nobody:nobody /usr/local/lsws/Example/html/mywordpresssite

In case of ubuntu this will work

sudo chown -R nobody:nobody /usr/local/lsws/Example/html/mywordpresssite

Now in the next step, we have to find two more permission sets. We have to specify the permissions for files and directories. First, we are going to set permission for the directories for that we will use

sudo find /usr/local/lsws/Example/html/mywordpresssite/ -type d -exec chmod 750 {} \;

Set permissions to 750 And for files permissons we use:

 sudo find /usr/local/lsws/Example/html/mywordpresssite/ -type f -exec chmod 640 {} \;

These permissions are required and suitable for the process and the proper functionalities properly.

Now we all done with the permissions part now we have to set set up wp-config.php. We copied the content of the sample file in the wp-config file. So we have to add some real value in order to word the wp-config properly. In the default file, you can see that they ask you for real value now we have to generate these values.

image 43

We can do so from the official API of WordPress for these use this command:

curl -s https://api.wordpress.org/secret-key/1.1/salt/
image 44

Once you run this command you will receive value like these. Copy the value from the terminal and replace these values in the wp-config.php file I am going to do this from the terminal using vi editors.

You can use this command to do so on your end:

vi /usr/local/lsws/Example/html/mywordpresssite/wp-config.php

this one is default one and have to replace with real values.

image 45

After updating with real values it look like.

image 46

The configurations for keys are now set up and now we have to set up database configurations in the wp-config.php file.

You remember the Database you created and the user for that. Now we have to add these in this file.

image 47

Now in this default configuration now we will add out real values in it.

image 48

All done for the wp setup. Its time to open and launch the final site.

Install WordPress with OpenLiteSpeed

Setup WordPress

Now we will go to the last WordPress Setup. First of all, you have to know how you can access your WordPress to setup. Be careful in this process. You can open your WordPress installation through your IP or server domain but check the firewall may in my case I was able to open the site on port 8088

http://<ip_address>:8088
WordPress

Here the process is started for installation. You have to select your language and click Continue.

Here you have to provide the required information. Username, Password, Site tile, and Email after providing all these clicks to the Install WordPress button.

Install WordPress with OpenLiteSpeed

You will receive the confirmation screen for the process.

image 51

Click to the login button and provide the detail to login.

image 52

After login, you can visit the admin dashboard and do whatever you want to.

image 53

Now you can do any operation regarding your site from here. Add any plugin, posting, and anything you want to do.

Benchmark of WordPress Site with LS Cache:

At the last, we are also going to check the benchmark for the WordPress Site with and without ls cache. In this way, we can evaluate how LS Cache effects the site. First, we will see the results without LS Cache and then we enable LS Cache and see the results. we are going to use h2load for performing benchmarks. You can visit here to check how to install it.

For the benchmark, we chose a fixed value which we are going to use after and before the LS Cache installation.

h2load -n10000 -c100 -m10 https://mydomain.com/

We are going to use this command that means we have three parameters here:

-n The number of total requests. we are going with 10000

-c The number of concurrent clients. we are going with 100

-m The max concurrent streams to issue per client. we are going with 10

Benchmark without enabling LS Cache

image 54
starting benchmark…
spawning thread #0: 100 total client(s). 10000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Server Temp Key: ECDH P-256 256 bits
Application protocol: h2
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done
finished in 1.61s, 6195.49 req/s, 154.30MB/s
requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 249.06MB (261158611) total, 120.81KB (123711) headers (space savings 96.91%), 248.42MB (260490000) data
min max mean sd +/- sd
time for request: 27.77ms 287.59ms 113.67ms 56.38ms 77.80%
time for connect: 175.54ms 317.87ms 206.94ms 43.20ms 83.00%
time to 1st byte: 205.29ms 438.45ms 287.47ms 71.38ms 66.00%
req/s : 62.07 106.24 77.41 16.47 76.00%

Benchmark after enabling LS Cache

image 55
[root@cyberpanelubuntu ~]# h2load -n10000 -c100 -m10 https://shoaibkhankhattak.tk/
starting benchmark…
spawning thread #0: 100 total client(s). 10000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Server Temp Key: ECDH P-256 256 bits
Application protocol: h2
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done
finished in 1.40s, 7117.72 req/s, 177.27MB/s
requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 249.06MB (261156355) total, 118.61KB (121455) headers (space savings 96.97%), 248.42MB (260490000) data
min max mean sd +/- sd
time for request: 22.52ms 190.04ms 94.97ms 32.20ms 66.87%
time for connect: 146.85ms 303.13ms 194.98ms 47.78ms 77.00%
time to 1st byte: 192.92ms 410.21ms 272.01ms 68.73ms 67.00%
req/s : 71.36 132.70 91.69 21.77 77.00%

Now you can see the difference between the both results.

Read More: HOW TO CHANGE TIMEZONE ON LINUX SERVER

Follow US on Facebook / Twitter  for update.

How to enable full/advanced WordFence protection on OpenLiteSpeed

Website security is always a fundamental and important part of any website especially WordPress. Today we will see how to enable full/advanced Wordfence protection on OpenLiteSpeed.

If you are using LiteSpeed Enterprise you don’t need to do anything as it is fully Apache compatible so Wordfence full protection will work out of the box. So you can stop now and enjoy your coffee.

However, if you are using OpenLiteSpeed then go ahead, make sure to use OpenLiteSpeed with CyberPanel, and ease your life.

What is WordFence?

Wordfence is one of the most popular WordPress scanner and firewalls. Wordfence comes in both free and premium versions. Wordfence has enough features to secure your websites like endpoint firewall, malware scanner, malicious IP addresses detection, 2FA, and all. In short, Wordfence is the most comprehensive WordPress security solution available. Wordfence is enough to secure your site.

Why do we need to configure OpenLiteSpeed for full Wordfence protection?

Setting up WordFence is a bit tricky in the case of OpenliteSpeed. With OpenLiteSpeed, you have to do some manual settings. In this article, we will discuss how to configure Wordfence with OpenliteSpeed to enable advanced firewall options.

Enable full Wordfence protection on OpenLiteSpeed:

  1. Install Wordfence on your WordPress site.
  2. Edit Vhost Configuration for Wordfence.
  3. Enable full Wordfence protection with CyberPanel.

Install Wordfence on your WordPress site:

The installation of Wordfence on your WordPress site is just like the installation on any plugin. Follow along the steps to install Wordfence.

Setp 1: Install Wordfence Plugin:

To install WordFence on your WordPress site first log in to your admin dashboard:

Go Plugins->add New

advanced wordfence protection on openlitespeed

Now search Wordfence in the search bar, You will receive the results for Wordfence select the first one (The one with the Wordfence logo) and Click install.

image 64

Setp 2: Setup Wordfence Plugin:

Once installation is done click Activate to activate the plugin:

image 65

After activation, they will ask you for an email address where they sent you emails regarding your website. Provide your email, click yes if you want to receive emails, check the box for agreement and press continue.

image 67

If you have a premium version enter the key here otherwise click on thanks and use the free version.

image 68

Now your Wordfence is installed and good to go. You can see the Wordfence on the left menu. When you click that you will see a notice to configure full/extended Wordfence protection.

image 69

Once you click the configuration a prompt appears that asks to download the .htaccess file. Click on download and press continue.

image 70

In the case of LiteSpeed Ent. configuration is done out of the box but in the case of OpenLiteSpeed, we’ve to perform some additional steps that we will discuss below. I found an official video guide for you to install Wordfence you can check that also.

Edit Vhost Configuration for Wordfence:

For OpenLiteSpeed you have to configure the Wordfence to enable Advanced WordPress Protection. Without setting these configurations to OpenLiteSpeed you can see that there is the Basic WordPress Protection.

image 71

To enable the advanced protection you have to access the OpenliteSpeed web server dashboard by navigating https://<your_ip>:7080. In the OpenLiteSpeed web, server Dashboard go to the VHost -> General

image 72

Go the end of page you will find the php.ini overwrite click the edit button.

image 73

add this to php.ini overwrite

php_value auto_prepend_file /path/to/wordfence-waf.php

Most Common path if you created site from cyberpanel

php_value auto_prepend_file /home/example.com/public_html/wordfence-waf.php

If you added the domain with CyberPanel then first you have to find the path of the wordfence-waf.php file. After adding this graceful restart the OpenLiteSpeed with this server did not get the changes.

image 74

Once done go back to your WordPress site and check the firewall you can see the Extended Protection level there.

image 75

Instead of doing this from the OpenLiteSpeed, you can install CyberPanel on your OpenLiteSpeed server, and then there is an easy way to do this. I will describe that in the next step.

Enable advanced firewall with CyberPanel.

When you have the CyberPanel installed on your server to manage your site you can follow the guide stated above but in this part of the article, I will tell you a simple way to do this using CyberPanel. To enable an extended or advanced level of protection using CyberPanel, you have to log in to CyberPanel using your credentials.

From you CyberPanel Dashboard go to the Websites ->list websites

image 76

You can see all of your websites there Click on the Manage button. To open the website dashboard.

image 77

Once the manage Dashboard for the web site is opened go to the configuration part and click the VHost

image 78

Go to the php.ini section

image 79

Add the following line to enable the extended protection.

php_value auto_prepend_file /home/example.com/public_html/wordfence-waf.php 

Now your extended protection is enabled .

image 81

Follow US on Facebook / Twitter  for update.

OpenLiteSpeed vs NGINX

Updated: On 22 September 2020.

OpenLiteSpeed is an open-source version of LiteSpeed Enterprise Web Server that shares the same code base so the same Enterprise-Grade performance. Today we will see the performance of openlitespeed vs nginx and we will look into various scenarios such as;

  1. Static file performance of openlitespeed vs nginx.
  2. Simple PHP file performance.
  3. WordPress site performance with and without LSCache and FastCGI Cache for NGINX.
Continue reading “OpenLiteSpeed vs NGINX”