How to install WordPress on OpenLiteSpeed for free

November 19, 2022 ・0 comments

wordpress on openlitespeed
Install WordPress on OpenLiteSpeed

Installing MariaDB server

MariaDB is a popular open-source alternative to MySQL database and is conveniently available in the standard repositories. First, update the packages list on the server with the command below.

sudo apt update

Once the packages list has been updated, run the following command to install the MariaDB server and MariaDB client on your server. You’ll be prompted to confirm to use storage space. Type Y and press Enter to continue with the installation.

sudo apt install mariadb-server

Next, perform the secure installation of MySQL on your server with the following command.

sudo mysql_secure_installation

The command prompt will take you through the wizard containing the questions below. Answer each of them as below:

Change the root password: N
Remove anonymous user: Y
Disallow root login remotely: Y
Remove test database and access to it: Y
Reload Privilege Table Now: Y

Now that MariaDB is installed and configured, we can create the first database.

Enter into the MySQL client by running the next command.

sudo mysql -u root -p

Then use the following commands to create a database and grant all permissions on that database to a new database user account.

mysql > CREATE DATABASE wordpress;
mysql > GRANT ALL ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'password';

Flush the privilege table and exit from the mysql shell.

mysql > flush privileges;
mysql > exit;

Your database is then all set for installing WordPress at a later step.

Configuring OpenLiteSpeed

Next, you need to configure the OpenLiteSpeed server to host your WordPress site. It requires you to set the right version of PHP processor, enable the rewrite module and several other features.

Configure your server to use lsphp80 as PHP processor instead of the default PHP processor.

Go to Server Configuration -> External App, and click the + button to add a new external app.

***

Select LiteSpeed SAPI App as the type and click the Next button.

***

Enter the following information:

Name: lsphp8.0
Address: uds://tmp/lshttpd/lsphp80.sock
Max Connections: 10
Environment: PHP_LSAPI_CHILDREN=10
LSAPI_AVOID_FORK=200M
Initial Request Timeout (secs): 60
Retry Timeout (secs): 0
Persistent Connection: Yes
Response Buffering: No
Command: lsphp80/bin/lsphp
Backlog: 100
Instances: 1
Priority: 0
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 1400
Process Hard Limit: 1500
***

Save the settings. Then go to Virtual Hosts -> Example ->  Script Handler tab and click the + button to add a new script handler.


***

Enter the following information:

Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: lsphp8.0
****

Save the settings. Then click the Graceful Restart button at the upper-left corner for the changes to take effect. Now enter server-ip-address/phpinfo.php in the browser address bar to test PHP with OpenLiteSpeed Web server. You should see that the default virtual host is now using PHP8.0.


****

After you make the changes, click the save icon on the top right corner of the panel as shown in the above screenshot.

Moving next to configure the rewrite module which is an essential requirement for WordPress feature. Go to the Virtual Hosts and click on the view icon.


***

Click on the General tab and edit the General options with the edit icon at the top right corner.


***

In the Document Root field, type $VH_ROOT/html/wordpress and click the save button at the top right corner.


***

Then again on the General tab of Virtual Hosts configuration, click the edit icon next to Index Filessection.

***

In the Index Files field, add index.php at the begin of the section. Then click the save button at the top right corner.

***

Next, go to the Rewrite tab of the Virtual Hosts configuration view and edit the Rewrite Controloptions.

***

Set Enable Rewrite and Auto Load from .htaccess to Yes and click save icon at the top right corner.

***

Once you’ve configured the OpenLiteSpeed server, Click the gracefully restart icon to apply the changes.

***

Downloading and extracting WordPress

Now that our server is configured to host WordPress, you should download and install WordPress.

Navigate to the virtual host root which is /usr/local/lsws/Example/html

cd /usr/local/lsws/Example/html/

Then download the latest version of WordPress using the wget command below.

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

Lastly, extract the zipped file. This will create a directory called ‘wordpress’ in /usr/local/lsws/Example/html

tar xvfz latest.tar.gz

Setting up the files ownership and permissions

Setting up the right ownership of files and folders will make sure that you do not encounter problems while installing or downloading new themes or plugins.

First, remove ownership from the Wordpress directory.

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

Then set 750 permissions to the directories and 640 to the files. You can do this with the following commands.

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

Once you configure the right permissions, you’re all set to open your website and install WordPress at your browser.

Installing WordPress

At this stage, you can open the WordPress installation wizard in your web browser by going to your domain if set or the IP address of your OpenLiteSpeed server.

The very first screen will ask you to choose your preferred language. Choose your language and click the Continue button.


***

In the second screen, WordPress prompts you to keep the database server information and credentials ready. Then just click the Let’s go! button.


***

In the next screen, fill up the fields as follows:
Database name: the database you created through the MySQL shell, wordpress in this example.
Username: Here you need to input the database user
Password: Type in the password of your database user
Database Host: localhost
Table Prefix: wp_ is the default table prefix. However, you can type something else to enhance the security of your website.

Once you fill up all the information, click the Submit button to confirm.

***

At this stage, you’ve configured the database connection for the WordPress installation. Next, you need to proceed and click the Run the Installation button to set up your WordPress site.


***

Next, you’ll be prompted to input the details of your website, create an administrator account and set a password.

Select the name of your website and choose an administrator username. It is recommended not to use a generic username such as “admin” or “administrator”.  A strong password will be generated automatically. Type in your email address and choose whether you want search engines to index your site or not.


***

Once you’ve filled up everything and ready, click the Install WordPress button. On successful installation, you will be prompted to log in.

Log in using the username and password you just created in the installation wizard. You’ll then see your very own WordPress website’s admin dashboard.

Post a Comment

If you can't commemt, try using Chrome instead.