OpenLiteSpeed WordPress Installation

WordPress has become the most popular content management systems for websites ever since its inception in 2003. WordPress is simple to use, and even hosting it yourself is not very hard, as you will see in this article. In this tutorial, we will cover the step by step instructions to install WordPress for an OpenLiteSpeed web server on a Linux system.

We will use OpenLiteSpeed as our HTTP server, and also install PHP and MariaDB (an open source implementation of MySQL) since WordPress requires them in order to function. This assortment of packages is commonly referred to as a LOMP stack (Linux, OpenLiteSpeed, MySQL, PHP). Once those packages are installed, we will go over the configuration of OpenLiteSpeed and MySQL, including initial setup of a database and user, before installing WordPress itself.

In this tutorial you will learn:

  • How to install and configure OpenLiteSpeed
  • How to install and configure MariaDB for MySQL
  • How to setup a MySQL user and database for WordPress
  • How to download and install WordPress
OpenLiteSpeed WordPress Installation
OpenLiteSpeed WordPress Installation
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Debian Linux or Red Hat Enterprise Linux based Linux distro
Software OpenLiteSpeed web server
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install OpenLiteSpeed, PHP, and MySQL




The first thing you will need to do is install the OpenLiteSpeed web server, if you do not already have it on your system. Please refer to our OpenLiteSpeed installation guide to get the software installed, then return to follow the instructions below when finished.

The next thing we will need to do is prep our Linux system with the proper software packages. WordPress can only run if we provide it with an HTTP server, PHP and its related modules, and a MySQL database. Open a terminal and type the following couple of commands to install PHP and MariaDB, which is an open source fork of MySQL:

On Debian and Ubuntu:

$ sudo apt install php mariadb-server mariadb-client php-mysql php-curl php-xml php-mbstring php-imagick php-zip php-gd

On CentOS:

$ sudo dnf install mariadb-server php-common php-curl php-xml php-mbstring php-imagick php-zip php-gd php-mysqlnd

This is a lot of packages to install, and yes, they are all required. Without some of the extra PHP modules, you will not get a perfect score in the “Site Health Status” section of the WordPress administrator dashboard.

Configure MySQL

One of the first things we should do is get our WordPress database ready. In order to do that, we first need to do some initial configuration of MySQL. To get started, execute the following command in terminal:

$ sudo mysql_secure_installation

Leave the first response blank and press enter. You should reply with y (yes) to the rest of the prompts, and configure a root password when prompted to do so. This setup only takes a moment to complete.

The initial setup of MySQL with mysql_secure_installation
The initial setup of MySQL with mysql_secure_installation

Create a database for WordPress

WordPress stores all of its post and page content, among other information, inside of MySQL. We will need to configure a MySQL user and database for WordPress to access with the following steps:

  1. Start by opening up MySQL with the root user:


    $ sudo mysql
    
  2. Create a new database for WordPress. In this example, we will call ours wordpress_db, but you can use whatever name you’d like.
    MariaDB [(none)]> CREATE DATABASE wordpress_db;
    
  3. Next, we need to create a new user that WordPress can use to access the database we just created. For this example, we’ll make our username wordpress_user and our password my_password. Replace the my_password text below with a secure password (and write it down somewhere for later):
    MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'my_password';
    
  4. Then, give the WordPress user full permissions on the WordPress database:
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
    
  5. Lastly, save the changes you’ve made to user permissions and exit MariaDB:
    MariaDB [(none)]> FLUSH PRIVILEGES;
    MariaDB [(none)]> exit
    
    Configuring MySQL database and user for WordPress
    Configuring MySQL database and user for WordPress

Download and install WordPress

OpenLiteSpeed should already be installed and running at this point, and that can be verified by opening a browser and navigating to loopback address 127.0.0.1:8088 or just localhost:8088 on your system.

Default OpenLiteSpeed page, indicating that our website is accessible
Default OpenLiteSpeed page, indicating that our website is accessible




Although OpenLiteSpeed is hosting our site (or lack of one) already, it’s best practice to configure a new virtual host file for our WordPress install. This will allow you more flexibility in the future if you want to host multiple websites or make changes to where the WordPress directory is installed, etc.

  1. First, let’s create the directory where we will store our WordPress website and copy the virtual host config file from the example site to be the template for our new WordPress site as well.
    $ sudo mkdir -p /usr/local/lsws/wordpress
    $ sudo cp -av /usr/local/lsws/conf/vhosts/Example /usr/local/lsws/conf/vhosts/wordpress
    
  2. Then, navigate to the OpenLiteSpeed web admin panel located at https://localhost:7080/login.php and log in with your admin user name and password. In case you have not yet configured one, see our guide on OpenLiteSpeed default password.
    Log in to the OpenLiteSpeed web admin
    Log in to the OpenLiteSpeed web admin
  3. Click on the virtual hosts tab and then the plus sign to add a new virtual host to OpenLiteSpeed.
    Virtual hosts tab inside of the OpenLiteSpeed web panel
    Virtual hosts tab inside of the OpenLiteSpeed web panel
  4. Now we will fill out the following information. Save your changes by clicking the disk icon when done.
    Virtual Host Name = wordpress
    Virtual Host Root = $SERVER_ROOT/wordpress
    Config File = $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
    Follow symbolic link = yes
    Enable Scripts/ExtApps = yes
    Restrained = yes
    
    Virtual host settings are filled out. Save when done
    Virtual host settings are filled out. Save when done

    Choose to generate the vhconf.conf file when prompted by the web panel.

  5. Perform a graceful restart when you are finished.



    Perform graceful restart for the changes to take effect
    Perform graceful restart for the changes to take effect

  6. Next, go to the Listeners tab, click on the default Listener, and click the plus sign as indicated in the screenshow below to add a new virtual host mapping.
    Adding a new virtual host mapping
    Adding a new virtual host mapping
  7. Enter wordpress for your virtual host, then list all the domains you are using. Or just put an * as a catch all.
    Finalizing the changes for our virtual host mapping
    Finalizing the changes for our virtual host mapping

    Click save when done, and perform another graceful restart.

Download and install WordPress

Now that we have our HTTP server configured and PHP and MySQL are ready to go, we can move on to the installation of WordPress itself.

  1. First, use wget to download the latest version of WordPress:
    $ wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
    
  2. Extract the tar archive into your WordPress site directory:
    $ sudo tar -xzvf /tmp/wordpress.tar.gz -C /usr/local/lsws
    
  3. Now we can get started with configuring WordPress. Open your internet browser and navigate either to the localhost address 127.0.0.1:8088 or your fully qualified domain name if you set one up. You should be greeted by the WordPress setup wizard. Click “Let’s go” to get started.

    Initial WordPress setup wizard
    Initial WordPress setup wizard



  4. Next, enter the database information that you configured earlier. The last two boxes (database host and table prefix) can be left at their default values. Click “Submit” when you’re finished.
    Fill out the MySQL database information we configured earlier
    Fill out the MySQL database information we configured earlier
  5. WordPress will attempt to make a connection with the database and let you know if it was successful. Assuming it was, click “Run the installation” to continue.
    WordPress has successfully connected to our MySQL database
    WordPress has successfully connected to our MySQL database
  6. The next screen will ask you for some general information about your new site. After you finish filling this out, click “install WordPress” at the bottom of the screen to finalize the installation.
    Fill out your site title, username, password, and email
    Fill out your site title, username, password, and email
  7. WordPress installation is now complete! You can click on the “log in” button to get started creating content.
    WordPress has installed successfully. Click log in to find the admin menu
    WordPress has installed successfully. Click log in to find the admin menu

    Note that to get back to the WordPress admin panel in the future, you can always use the URL http://127.0.0.1:8088/wp-admin (or replacing 127.0.0.1 with your fully qualified domain name).

    WordPress admin menu
    WordPress admin menu




Your WordPress site should now be accessible from http://127.0.0.1:8088 or your fully qualified domain name.

Our WordPress site is now up and running
Our WordPress site is now up and running

Closing Thoughts

This tutorial has shown you how to install top notch components to run a WordPress website on a Linux system. WordPress is an awesome content management system with virtually endless configuration. It’s so simple that someone without any HTML, CSS, or PHP coding experience can have a great looking website. Be sure to browse through the WordPress menus to see all the customization power you have at your fingertips.



Comments and Discussions
Linux Forum