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
|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
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – 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
$ 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.
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.
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:
- Start by opening up MySQL with the root user:
$ sudo mysql
- 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;
- 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_userand our password
my_password. Replace the
my_passwordtext below with a secure password (and write it down somewhere for later):
MariaDB [(none)]> CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'my_password';
- Then, give the WordPress user full permissions on the WordPress database:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@'localhost';
- Lastly, save the changes you’ve made to user permissions and exit MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
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.
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.
- 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
- 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.
- Click on the virtual hosts tab and then the plus sign to add a new virtual host to OpenLiteSpeed.
- 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
Choose to generate the vhconf.conf file when prompted by the web panel.
- Perform a graceful restart when you are finished.
Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!
- 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.
wordpressfor your virtual host, then list all the domains you are using. Or just put an
*as a catch all.
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.
- First, use wget to download the latest version of WordPress:
$ wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
- Extract the tar archive into your WordPress site directory:
$ sudo tar -xzvf /tmp/wordpress.tar.gz -C /usr/local/lsws
- 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.
- 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.
- 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.
- 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.
- WordPress installation is now complete! You can click on the “log in” button to get started creating content.
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).
Your WordPress site should now be accessible from http://127.0.0.1:8088 or your fully qualified domain name.
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.