This article will help you install WordPress with the LSCache plugin on OpenLiteSpeed using LSPHP. We are also going to see how we can use free Lets Encrypt SSL to secure your WordPress site.
This article guides you through installing and configuring OpenLiteSpeed web server, MariaDB as a database management system, LiteSpeed PHP, LetsEncrypt SSL to secure your website and Pure-FTPD (File Transfer Protocols Daemon) in case you want to use FTP to transfer WordPress files from your computer to server. The result would be to create a WordPress site on a domain (faizan.cyberpanel.net with the issuance of SSL Certificate) using OpenLiteSpeed as a web server.
A repository is a storage location where software packages are retrieved and installed on a server. We can install OpenLiteSpeed without compiling it by directly adding the LiteSpeed repository. Use the command below to enable the repository:
sudo rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
Now that we can access LiteSpeed repositories, we can set up the server along with the MariaDB database management system by using the following command:
sudo yum install OpenLiteSpeed mariadb-server
Different versions of PHP are available in LiteSpeed repositories. We will install PHP version 5.6 along with the PHP extension needed to connect with the MariaDB database management system.
sudo yum install lsphp56 lsphp56-mysql
LSPHP denotes LiteSpeed PHP. You can also search for various available extensions. Replace 56
with the corresponding PHP version to search for extensions of other PHP versions:
yum search lsphp56
You can also install all the extensions for LSPHP 5.6 using the command below:
sudo yum install lsphp56-*
To execute and change the default admin password for OpenLiteSpeed's WebAdmin Console, use the following command and set it to 123456
:
sudo /usr/local/lsws/admin/misc/admpass.sh
It will ask for a username but by default, the admin
username is used. You can press Enter to accept, and use the password 123456
on a temporary basis. Later, you can change your temporary password to a strong password for protection.
By default, OpenLiteSpeed will use the PHP at /usr/local/lsws/fcgi-bin/lsphp5
We will create a symlink to our installed PHP version so that OpenLiteSpeed can use the PHP 5.6 that we installed earlier because it contains the MySQL extension which is required by WordPress.
sudo ln -sf /usr/local/lsws/lsphp56/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5
Now, the PHP version 5.6 at /usr/local/lsws/lsphp56/bin/lsphp
will be used by OpenLiteSpeed to process PHP files.
Start MariaDB by using following command:
sudo systemctl start mariadb
Enable MariaDB service automatically, when we boot our system:
sudo systemctl enable mariadb
Run the first time command to set up and configure MariaDB:
sudo mysql_secure_installation
First, it will ask for the root password for Maria DB, but since we haven't set one, press the Enter key to proceed. Now, it will ask you to set the root password. Provide a secure and strong root password to log into MariaDB.
For the rest of the questions, you can press Enter to continue and you will successfully install MariaDB on your server along with OpenLiteSpeed and LSPHP.
Now we will confirm the OpenLiteSpeed web page and Admin interface.
You can check the status of your OpenLiteSpeed web server using the following command, which provides a LSWS PID:
sudo service LSWS status
You can also browse to your server's domain name or IP address on port 8088 to view the following OpenLiteSpeed default page:
https://your-IP-Address:8088
Now you have successfully installed OpenLiteSpeed web server which is running on port 8088.
Log into the OpenLiteSpeed administrative interface by browsing to your server's domain name or IP address on port 7080:
https://your-IP-Address:7080
You will see a browser warning for an invalid SSL certificate, but you can proceed by clicking the "Proceed" link as shown:
After proceeding, it will take you to the OpenLiteSpeed administrative interface, where you will enter your username and default password.
Now you are on your main server management dashboard.
Log into your the OpenLiteSpeed administrative interface. Go to Listeners > Listener List > View/Edit Button > from main menu bar of your dashboard, and change port 8088
to conventional port 80
. Save the changes and restart the server.
Now we have installed OpenLiteSpeed web server, MariaDB and PHP version 5.6 on Centos 7. OpenLiteSpeed web server and its administrative interface provides useful features to run and manage your websites in a user-friendly environment.
WordPress is the most powerful website creation tool in the world. It is the prevalent content management system (CMS). WordPress owes its popularity to a user-friendly interfance for blog, website, and post management that doesn't require a user to know any programming languages. WordPress websites are set up on top of a database back-end system that uses PHP scripts to execute the processing of dynamic content.
Let's set up WordPress with OpenLiteSpeed on CentOS 7.
At this point, you must have successfully installed the above prerequisites to move ahead.
To create a database and database user for WordPress, we need to log into MariaDB with the following command:
mysql -u root -p
It will ask for the administrative password for MariaDB that you entered during installation.
Once you are logged into MariaDB, you will need to create a database for WordPress. You may choose any name for your database, but we will use cyberpanel
for a simple example.
CREATE DATABASE cyberpanel;
Now we will create a database user and grant it access to manage the database that has just been created. We will create a user by the name of cyberpaneluser
but, again, you may name it whatever you like. Also, you can replace the password in the command section to keep it strong. We will be using password
for simplicity.
GRANT ALL ON cyberpanel.* TO [email protected] IDENTIFIED BY 'password';
Use the flush command to make your changes available to the current MariaDB process.
FLUSH PRIVILEGES;
Now, exit out of MariaDB to your regular shell.
exit
Earlier we installed PHP 5.6 from LiteSpeed repositories. WordPress requires some additional extensions that we will install now using the command below:
sudo yum install lsphp56-gd lsphp56-process lsphp56-mbstring
Now, these extensions will automatically be available to OpenLiteSpeed web server to run WordPress.
For the configuration of a Virtual Host, navigate to OpenLiteSpeed's administrative interface by browsing to your server's domain name or IP address on port 7080 i.e. https://your-IP-Address:7080
Enter your username and default password to log in, then go to Virtual Hosts from the main dashboard menu bar on the left and follow the steps below:
Press the add button on the top right corner. The following window will be opened.
faizan.cyberpanel.net
)/home/wordpress
)$SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
)Yes
to Enable Scripts/External Apps.Yes
to Enable Restrained.Now a Virtual Host has been created and is called "faizan.cyberpanel.net":
Navigate to Virtual Hosts > faizan.cyberpanel.net > General and press the edit/view button to make the following changes:
$SERV_ROOT
or $VH_ROOT
. This path will be similar to the path of Virtual Host Root, i.e. /home/wordpress.
faizan.cyberpanel.net
, and is the domain where WordPress will be running.www.faizan.cyberpanel.net
Navigate to Virtual Hosts > faizan.cyberpanel.net > General > Index Files and press the edit/view button. In the Index files field, add index.php
before index.html
to allow PHP index files to take precedence. Now, save changes and restart your server.
Navigate to Virtual Hosts > faizan.cyberpanel.net > Rewrite Rules, press the edit/view button, and make the following changes:
YES
.YES
.Navigate to Virtual Hosts > faizan.cyberpanel.net > Script Handler, press the edit/view button, and make the following changes:
lsphp
.Litespeed SAPI
from the drop-down list.[server level] lsphp
.From the OpenLiteSpeed administrative main dashboard, navigate to: Listeners > Listener List > Virtual Host Mappings, press the edit/view button, and make the following changes:
faizan.cyberpanel.net
.faizan.cyberpanel.net
At this point, we have completed the necessary virtual host tasks required to run WordPress on faizan.cyberpanel.net. Now, we will install and configure WordPress in the /home/wordpress
directory on CentOS 7.
Now we are ready to download and install WordPress to the /home/wordpress
directory that we set up on the Virtual Host Root and Document Root.
cd /home wget https://wordpress.org/latest.tar.gz
Extract WordPress:
tar xzvf latest.tar.gz
Now, WordPress has been installed in /home/wordpress
.
Set permissions on the WordPress directory so that the user which runs the web server may make changes through the WordPress interface.
chown -R nobody:nobody /home/wordpress/
Now we have successfully downloaded and extracted WordPress in the /home/wordpress
directory.
Now, with the files downloaded to /home/wordpress
, we can access WordPress by going to the faizan.cyberpanel.net/index.php
domain that we set up for running WordPress in Virtual Hosts.
Press Continue to proceed; the next page will ask you to enter the following things for validation:
cyberpanel
.cyberpaneluser
.password
.After adding the above information, enter Site Title, Username, Password, and Your Email for authentication.
Press the Install WordPress button.
Enter your username and password to log into the main dashboard of your WordPress website:
The LSCache plugin for WordPress works by generating static HTML pages of your WordPress website and saving them on your server. The main benefit of this feature is that when a user tries to access a website, LSCache provides a lighter HTML page, instead of running the heavy PHP scripts, and gathering data from the beginning. LSCache is installed on servers to improve the load time of a website through this process.
The LSCache server module installed and enabled itself when you first set up OpenLiteSpeed. You need to set the LSCache parameters to the following by going to Openlitespeed's Administrative Interface > Main Dashboard > Server Configuration > Modules > Server Modules Definition > View/Edit Button > Module Parameters.
checkPrivateCache 1 checkPublicCache 1 maxCacheObjSize 10000000 maxStaleAge 200 qsCache 1 reqCookieCache 1 respCookieCache 1 ignoreReqCacheCtrl 1 ignoreRespCacheCtrl 0 enableCache 0 expireInSeconds 3600 enablePrivateCache 0 privateExpireInSeconds 3600
Save changes and restart your server.
Now, go to Virtual Hosts > faizan.cyberpanel.net > Rewrite Rules, press the edit/view button, and make the following changes:
YES
.YES
.your.domain.com/wp-admin
).LiteSpeed Cache
.X-LiteSpeed-Cache: hit
This means the LSCache plugin for WordPress is successfully activated and is caching your site.
SSL stand for Secure Socket Layer, and it is used to ensure privacy, authentication and data protection in Internet communication. It uses the HTTPS protocol and encryption to secure your website from threats and an insecure environment.
To install acme.sh, execute the command below:
wget -O - https://get.acme.sh | sh
You will see an output in which acme.sh is installed to /root/.acme.sh/ directory.
The following command is used to issue a LetsEncrypt certificate for a single domain, i.e. faizan.cyberpanel.net
.
/root/.acme.sh/acme.sh --issue -d faizan.cyberpanel.net -w /home/wordpress
/root/.acme.sh/acme.sh
is the path where acme is installed.faizan.cyberpanel.net
is the domain name that needs to be secured./home/wordpress
is the document root for that domain. It needs to be supplied so that acme can do its verification.In the output, the certificate key and full chain certificate key are outlined in red. Now you will need to enter these two keys in the Virtual Hosts area.
Navigate to Virtual Hosts > faizan.cyberpanel.net > SSL > SSL Private Key and Certificate, press the edit/view button, and make the following changes:
YES
.Go to Listeners > Add Listener, and make the following changes:
faizan.cyberpanel.net
.ANY
.443
, which is the standard TCP port used for SSL.YES
.Go to Listeners > Listeners faizan.cyberpanel.net > Virtual Host Mappings > SSL > SSL Private Key and Certificate, press the edit/view button, and make the following changes:
YES
.Go to your browser visit your index page, like so: https://faizan.cyberpanel.net/index.php
You have now successfully installed LetsEncrypt SSL on CentOS 7 for the domain faizan.cyberpanel.net
. You can follow the steps mentioned above to do the same for your own website in an easy way.