How to Install WordPress on RHEL 8 with Apache

WordPressThis is a very popular choice CMS (Content Management System) that accounts for nearly 43%All websites according to

High-traffic sites such a eCommerceWordPress has been able to maintain its dominance over its competitors in the news, blogs, and news websites. Joomla, Shopify, Wix.

WordPressIt is free and open-source. It allows you to make almost any customization you need. It allows you to create high-performance, SEO-friendly websites that are mobile responsive and easy-to-customize.

This guide will show you how to install. WordPressOn RHEL 8With an Apache webserver.


Before you start, make sure that Apache, MariaDB, and PHP are installed on RHEL 8These are the components of the LAMP stack.


The latest version WordPressIt is necessary PHP 7.4Higher. The default AppStreamOnly repository PHP 7.2this version is insecure, and is no longer supported. You can install the most recent PHP version using the Remi repository instead. Let’s get started now that we have all the requirements in place.

Step 1: Create a WordPress Database

We will start by creating the database. WordPressinstallation, which is used to store all files during and following the installation.

Log in now to the MariaDB database:

$ sudo mysql -u root -p

Once on the MariaDBShell, create the database user and the database user, and grant all privileges to the user.

CREATE DATABASE wordpress_db;
GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongPassword';

Save the changes and exit MariaDB prompt.

Create WordPress Database
Create a WordPress Database

Step 2: Download WordPress in RHEL and install it

With the WordPressAfter the database is created, the next step of action is to download or configure it. WordPress. The most recent WordPress version is at the time of publishing this guide. 5.9.1.

To download WordPressUse the wget commandYou can download the binary file directly from the official website.

$ wget
Download WordPress in RHEL
RHEL: Download WordPress

Next, extract the tarball files:

$ tar -xvf latest.tar.gz

Next, we will copy the wp-config-sample.phpSend an email wp-config.phpWordPress’s base configuration is derived from. To do this, run.

$ cp wordpress/wp-config-sample.php wordpress/wp-config.php

Next, edit wp-config.php file.

$ vi wordpress/wp-config.php

Modify the values to correspond with your database name, database username, and password, as shown in the image.

WordPress Database Settings
WordPress Database Settings

Save the changes, then exit the configuration file.

Next, copy this WordPressdirectory to the root document.

$ sudo-cp –R WordPress /var/www/html/

You must ensure that the directory owner and permissions are as follows:

$ sudo chown -R apache:apache /var/www/html/wordpress
$ sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress R
$ sudo chmod -Rf 775  /var/www/html

Step 3: Create Apache WordPress VirtualHost File

Also, we will need to create a configuration folder for WordPress to point client requests at the WordPress directory. As shown, we will create the configuration files.

$ sudo vi /etc/httpd/conf.d/wordpress.conf

Copy and paste the following lines into your configuration file.

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress

<Directory "/var/www/html/wordpress">
FollowSymLinks Options Indexes
AllowOverride All
Require all granted

ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log common

Save and exit the configuration file.

Restart Apache to apply the changes.

$ sudo systemctl restart httpd

Step 4: Configure SELinux for WordPress

In most cases, RHEL 8Comes with SELinux enabled. This can be a problem especially when installing web apps. This is why we need to configure the correct SELinux context for the application. /var/www/html/wordpress directory.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?"

Follow these steps to allow the changes in force

$ sudo restorecon -Rv /var/www/wordpress

Next, reboot your system.

NOTEEnsure that you have a working internet connection before you start a reboot ApacheAnd MariaDBServices can be enabled so that they start automatically upon boot.

$ sudo systemctl enable httpd
$ sudo systemctl enable mariadb

Step 5: Finish WordPress Installation

The final step is to finish the installation using a web browser. Launch your browser and browse your server’s IP address:


On the first page, select your preferred installation language and click ‘Continue’.

WordPress Installation Language
WordPress Installation Language

In the next step, fill in your Site’s details.

WordPress Site Details
WordPress Site Details

Then scroll down and click ‘Install WordPress’.

WordPress Installation
WordPress Installation

The WordPress installation will be completed in a flash! To log in, click the ‘Login’ button.

WordPress Login
WordPress Login

On the login screen, provide the username and password and click ‘Log In‘.

WordPress Admin Login
WordPress Admin Login

This will take you to the WordPress dashboard. This is where you can customize and install plugins and rich themes to your website.

WordPress Dashboard
WordPress Dashboard

And that’s it! Congratulations! WordPressOn RHEL 8.

Leave a Reply

Your email address will not be published. Required fields are marked *