How to Install WordPress on RHEL 8 with Nginx

Content Management Systems are what you need. WordPress reigns supreme. WordPress powers nearly 43%It is followed by HubSpot CMS and Joomla, Drupal, Wix, Wix, Shopify, Wix, Wix, Wix, Wix, Wix, Wix, Wix, Wix, Wix, Wix, Shopify, and others. It is completely opensource and free to download.

This guide will show you how install Worpress on RHEL 8, using the Nginx webserver.


Before we start, here are some requirements you should have.

Let’s get started now that we have all the requirements in place.

Step 1: Create a WordPress Database

We will begin by creating the database to install WordPress. This database stores all WordPress files.


Log in to the site first. MariaDB database:

$ sudo mysql -u root -p

Once you log in, create a WordPress database and a database user. Then, grant all privileges the database user.

MariaDB [(none)]> CREATE DATABASE wordpress_db;
MariaDB [(none)]>GRANT ALL ON wordpress_db.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongPassword';
MariaDB [(none)]> EXIT;
Create WordPress Database
Create a WordPress Database

Step 2: Install PHPFPM and Additional Modules

The PHP-FPM (FastCGI Process ManagerAlternatives: FastCGIdaemon for PHP allows a webserver handle high loads. We will therefore install PHP-FPMAlongside other PHP modules like shown

$ sudo dnf install php php-mysqlnd php-pdo php-gd php-mbstring php-fpm

Next, enable and begin the PHP-FPM daemon.

$ sudo systemctl enable php-fpm
$ sudo systemctl start php-fpm

The PHP-FPMService may need some modifications. You can edit the file.

$ sudo nano /etc/php-fpm.d/www.conf

By default, the group and user attributes are set. apache. Modify this to nginxThese are the details.

Configure PHP-FPM
Configure PHP FPM

Save and exit the configuration file. Then, restart. PHP-FPMThese changes are effective immediately.

$ sudo systemctl restart php-fpm

You must confirm that the service works.

$ sudo systemctl status php-fpm
Check PHP-FPM Status
Check PHP-FPM Status

Step 3: Install WordPress in RHEL

Moving on, we will download the WordPress binary files from the official WordPress download page. The file can be downloaded in either a zip or tarball format.

Run the following commands from the command line wget command:

$ wget

After the download is completed, unzip the file.

$ unzip

This extracts the file into a folder called ‘WordPress‘.

Next, copy the wp-sample-config.phpSend an email to wp-config.php file.

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

We will modify the wp-config.php file. This is one core WordPress file that contains information about your server as well as installation details.

$ sudo vi wordpress/wp-config.php

Navigate to the database section and enter the database name, password, and database user.

WordPress Database Settings
WordPress Database Settings

Save the changes, then exit the configuration file.

Next, copy the WordPressFolder to the /usr/share/nginx/htmlset the directory ownership permissions and path as follows

$ sudo cp -R wordpress /usr/share/nginx/html
$ sudo chown -R nginx:nginx /usr/share/nginx/html
$ sudo chmod -R 775 /usr/share/nginx/html

Step 4: Configure Nginx in WordPress

Next, create a server block for WordPress. This is how it should be done.

$ sudo vim /etc/nginx/conf.d/wordpress.conf

These lines should be added.ServerLocation / Don’t forget to replace with your server’s domain name.

server {
listen 80;

root /usr/share/nginx/html/wordpress;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$args;

location = /favicon.ico {
log_not_found off;
access_log off;

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ 
Expires maximumlocation = /robots.txt
log_not_found off;

location = /robots.txt 

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Save the configuration file, and exit it.

Next, modify the Nginx main configuration.

$ sudo vim /etc/nginx/nginx.conf

Navigate to Server section. Find the line that starts with RootSpecify the route to the event. webroot directory.

Configure Nginx for WordPress
Configure Nginx for WordPress

Save the changes, then exit the configuration file.

Now check to verify that all the changes have been made. NginxYou are allowed to be normal

$ sudo nginx -t

The output shows that everything is fine and we can move forward.

Check Nginx Configuration
Check Nginx Configuration

Restart to take into account all changes. Nginx PHP-FPM services.

$ sudo systemctl restart nginx
$ sudo systemctl restart php-fpm

Also, don’t forget to set SELinuxTo permissive. Edit the SELinux configuration file to do this.

$ sudo vim /etc/selinux/config

Set the SELinuxValue Permissive. Save the changes, then exit the configuration file.

Step 5: Finalize WordPress installation from a web browser

All configurations are now in place. Now, you need to finish the installation via your web browser. To do so, launch your web browser and browse your server’s IP address


Select the installation language and click ‘Continue’.

WordPress Installation Wizard
WordPress Installation Wizard

Next, fill out the required information including Site title, Username and Password.

WordPress Site Details
WordPress Site Details

Then scroll down and click on the ‘Install WordPress’ button.

WordPress Installation
WordPress Installation

Before you realize it, the installation is complete. To finalize the setup, click on the ‘Log in‘ button.

WordPress Admin Login
WordPress Admin Login

This will take you directly to the Login Page. Simply provide your username and password and click on the ‘Login’ button.

WordPress Login
WordPress Login

This brings you the fresh and crisp WordPress dashboard. This is where you can quickly create and style your website or blog with various themes and plugins.

And that’s it as far as installing WordPressOn RHELWith NginxConcerning. We hope that you enjoyed this guide.

Leave a Reply

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