Table of Contents

Welcome back!

+ In Part 2, we will focus on how to get a WordPress instance set up and running on CentOS 7 using the OpenLiteSpeed web server

+ As mentioned in Part 1 of this series, Cloud Servers can do even more than Cloud Hosting. As a result, you can completely apply the knowledge in this Part 2 to Cloud Server without any difficulty at all, even outperforming Cloud Hosting.

PREREQUISITES

+ Before you begin this guide, there are some important steps that you must complete to prepare your server

    • This guide will not cover install OpenLiteSpeed or MySQL. Please check out Part 1 for more details
    • A Centos OS7 x 64 server (Cloud Hosting or Cloud Server) instane

+ If you have not had a Cloud Hosting or Cloud Server or Domain Name. BUY RIGHT NOW so that you can start leaning and practicing with 1Byte

+ When you are finished preparing your server using the guides linked to above, you can proceed with this tutorial

Let's GET YOUR HANDS WET

Step 1: Login into your Cloud Server/ Cloud Hosting

+ In Part 1, I explain how to log in in great detail. If you don’t know how, please read it.

Step 2: Login into WebAdmin Console and Configure OpenLiteSpeed

+ Log into OpenLiteSpeed’s administrative interface (WebConsole Admin)

				
					https://<server-ip>:7080
				
			

+ If prompted, log in using the username and password you configured for OpenLiteSpeed in Part 1 – Step 6

+ Next, we will configure External App

1) Go to Server Configuration on the left-menu bar

2) Select External App tab

3) Click on Add button

2022 05 19 162615 24
Do follow the instructions

+ Remember to select LSPHP setup select litespeed SAPI APP to optimize php for best performance

2022 05 19 162615 26
Do follow the instructions

+ Setting parameters for LiteSpeed SAPI App

+ There are many parameters:value that need to be set up for this step. Please input the values (to the right of the colon) corresponding to the parameters (to the left of the colon) based on Sample Data in the code block below

				
					#Sample Data
Name: lsphp74
Address: uds://tmp/lshttpd/lsphp74.sock
Max Connections: 50
Environment:
PHP_LSAPI_CHILDREN=50
LSAPI_AVOID_FORK=200M
Initial Request Timeout (secs): 60
Retry Timeout : 0
Response Buffering: no
Start By Server: yes (Thorough CGI daemon)
Command: $SERVER_ROOT/lsphp74/bin/lsphp
Back Log: 100
Instances: 1
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 1400
Process Hard Limit: 1500
				
			

+ If you are still confused, please check out this video

+ After that, configure Script Handler is a MUST

1) Go to Server Configuration on the left-menu bar

2) Select Script Hander tab

3) Click on Edit button

2022 05 19 162615 27
Do follow the instructions

4) Switch to lsphp74 from Handler Name

5) Click Save button

2022 05 19 162615 28
Do follow the instructions

Step 3: Configure the Virtual Host for WordPress

+ We will be modifying the default virtual host that is already present in the OpenLiteSpeed configuration so that we can use it for our WordPress installation.

1) Go to Virtual Hosts on the left-menu bar

2) Click on Add button

2022 05 19 162615 29
Do follow the instruction

+ Next, we need to set parameter:value for this new Virtual Host. Please input the values (to the right of the colon) corresponding to the parameters (to the left of the colon) based on Sample Data in the code block below

				
					#Sample Data
Virtual Host Name : 1byte-demo.com
Virtual Host Root : $SERVER_ROOT/1byte-demo.com/
Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/1byte-demo.com.conf
Follow Symbolic Link: Yes
Enable Scripts/ExtApps: Yes
Max Keep-Alive Requests: 1000
Restrained: Yes
ExtApp Set UID Mode: Server UID
				
			

NOTE:

+ When you press the Save button, the system will report an error on line 4, the file

.conf does not exist, so we will click on CLICK TO CREATE to let the system create this file for you.

+ Next, we need to configure General section in General tab, in your Virtual Host

2022 05 19 162615 30
2022 05 19 162615 31
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

+ Same as above, configure Index Files section in General tab of your Virtual Host

2022 05 19 162615 32
2022 05 19 162615 33
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

NOTE:

+ It should be noted that the space between index.php and index.html is 1 space, they are separated by 1 space. Not separated by commas

+ Continue to configure Expires Settings in General tab of your Virtual Host

2022 05 19 162615 34
				
					#copy the following declaration into "Expires By Type"
image/*=A31536000, text/css=A31536000, application/x-javascript=A31536000, application/javascript=A31536000, font/*=A31536000, application/x-font-ttf=A31536000
				
			
2022 05 19 162615 35
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

+Configure Virtual Host Log in Log tab

2022 05 19 162615 36
				
					#Sample Data
Use Servers Log: Yes
File Name: $VH_ROOT/logs/error.log
Log Level: ERROR
Rolling Size (bytes): 10M
				
			
2022 05 19 162615 37
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

+ Switch to Access Log and modify as the Sample Data in block code does

2022 05 19 162615 38
				
					#Sample Data
Log Control: Own Log File
File Name: $VH_ROOT/logs/access.log
Piped Logger: Not Set
Log Format: Not Set
Log Headers: Not Set
Rolling Size (bytes): 10M
Keep Days: 30
Bytes log: Not Set
Compress Archive: Yes
				
			
2022 05 19 162615 39
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

+ Configure Access Control in Security tab

2022 05 19 162615 40
2022 05 19 162615 41
Only put asterisk in Allow List

+ Navigate to Rewrite tab, and add the following rules in Rewrite Rules section

				
					#Remember to change your domain name in here
rewriteFiler /usr/local/lsws/1byte-demo.com/html/.htaccess
				
			
2022 05 19 162615 42
Follow the instructions as shown above

+ Also in the same Rewrite tab, configure the Rewrite Control section based on Sample Data in code block

2022 05 19 162615 43
				
					#Sample Data
Enable Rewrite: Yes
Auto Load from .htaccess: Yes
Log Level: Not Set
				
			
2022 05 19 162615 44
Follow the instructions as shown above. Those that are not mentioned, just leave them as default

+ Finally, we need to connect our Virtual Host file to port 80

2022 05 19 162615 45
Follow the instruction on this image
				
					#Sample Data
Enable Rewrite: Yes
Auto Load from .htaccess: Yes
Log Level: Not Set
				
			
2022 05 20 130153

+ With all of the above configuration out of the way, we can now gracefully restart the OpenLiteSpeed server to enable our changes. It is a square button, green background with white arrow icon, located on the top right hand side

2022 05 19 162615 19
The Greaceful Restart button

Step 4: Prepare the Virtual Host and Document Root Directories

+ Back to your terminal, now we will create website root directory

				
					mkdir /usr/local/lsws/1byte-demo.com/
mkdir /usr/local/lsws/1byte-demo.com/{html,logs}

				
			

NOTE:

/usr/local/lsws/1byte-demo.com/html/This absolute path is where all your website data is stored

+ Next, create .htaccess file

				
					cd /usr/local/lsws/1byte-demo.com/html
nano .htaccess

#Copy these line into your .htaccess file
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

				
			

+ Now you need to grant control for your web root directory

				
					chown -R nobody:nobody /usr/local/lsws/1byte-demo.com/html
				
			

Step 3: Create a Database and Database User for WordPress

+ We will start by creating a database and database user for WordPress to use

				
					mysql -u root -p
				
			

+ You will be prompted to enter the MariaDB administrative password that you already created in Part 1 – Step 7. Afterwards, you will be dropped into a MariaDB prompt

+ Running these commands to create <db_user>, <db_password>, and <db_name>

				
					#create <db_name> named "wordpress"
CREATE DATABASE wordpress;

#create <db_user> named "wordpressuser"
#create <db_password> has value is "password"
#Grant access right of <db_user> to <db_name>
GRANT ALL ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';

#Flush the changes you’ve made to make them available to the current MariaDB process
FLUSH PRIVILEGES;

#exit out of the MariaDB prompt to get back to your regular shell
exit
				
			

NOTE:

+ As a goal of maintaining things simple, I’ve set the values as follows:

    <db_name> = wordpress

    <db_password> = password

    <db_user> = wordpressuser

+ You should change these values to your liking, especially the value for <db_password> needs to be a strong password and not be easily guessed.

+ If you are still confused, please check out the video below

Step 5: Install and Configure WordPress

+ We are now ready to download and install WordPress. Move to your home directory and download the latest version of WordPress by typing

				
					#Move into the virtual host root directory
cd /usr/local/lsws/Example/html/

#Download wordpress
wget http://wordpress.org/latest.zip

#Extract the arrchive
unzip latest.zip

#Grant the webserver user write permission to create wp-config.php
chown -R nobody:nobody wordpress
				
			

+ Extract the archive and enter the directory by typing

				
					tar xzvf latest.tar.gz
cd wordpress
				
			

+ You can copy the sample WordPress configuration file to wp-config.php, the file that WordPress actually reads and processes. This is where we will put our database connection details

				
					cp wp-config-sample.php wp-config.php
				
			

+ Open the configuration file so that we can add our database credentials

				
					nano wp-config.php
				
			

+ You need to find the settings for DB_NAME, DB_USER, and DB_PASSWORD so that WordPress can authenticate and utilized the database that we already did in Step 2. Please replace these values with yours, not mine

				
					#Put <db_namer> in Step 2 at here
define('DB_NAME', 'wordpress');

#Put <db_user> in Step 2 at here
define('DB_USER', 'wordpressuser');

#Put <db_password> in Step 2 at here
define('DB_PASSWORD', 'password');
				
			

+ Remember to save (Ctrl + O), and exit (Ctrl +X) when you are finished

+ If you are still confused, please check out this video

+ Now, we are ready to copy the files into our document root. To do this, type

 

				
					sudo cp -r ~/wordpress/* /usr/local/lsws/Example/html/
				
			

+ Give permission of the entire directory structure to the user that the web server runs under so that changes can be made through the WordPress interface

 

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

Step 6: Finish the Installation Through the WordPress Interface

+ We are now ready to download and install WordPress. Move to your home directory and download the latest version of WordPress by typing

				
					cd ~
wget https://wordpress.org/latest.tar.gz
				
			

+ Give permission of the entire directory structure to the user that the web server runs under so that changes can be made through the WordPress interface