How to Install WordPress on Rocky Linux

How to Install WordPress on Rocky Linux
November 15, 2023

WordPress has evolved from being nothing more than a blogging platform to one of the most widely used Content Management System (CMS) tools on the planet. WordPress can be used as a company site, an e-commerce solution, a social network, help forum, video site, online portfolio, and so much more.

Although you might be tempted to go with a paid version of WordPress, such as those found on, a better alternative might be a self-hosted instance. And if you have a spare Rocky Linux instance, you're already halfway there.

Let's walk through the steps for installing WordPress on Rocky Linux. It's far easier than you might think, but does require a number of steps.

With that in mind, let's get to it.

What you'll need

The only things you'll need to complete this project are a running instance of Rocky Linux and a user with sudo privileges. Of course, if you plan on making this WordPress deployment available to the public, you'll also need a domain name set up to point to the hosting server. We're only going to deal with the basic installation of WordPress, so if you need to work with a domain, you'll want to make sure you have everything necessary to make that work.

Once you have those things ready, it's time to install.

Installing the web and database server

The first thing to do is install the web and database server. In this tutorial, we’re going to use NGINX as our web server, but you could easily use Apache or any other web server of your choosing that supports PHP. 

To get started, log into your server, open a terminal window, and install NGINX with the command:

sudo dnf install nginx -y

Set NGINX to start on boot, and start right now with the command:

sudo systemctl enable --now nginx

Next, we’re going to install the relational database that Wordpress uses to store all the configuration and content for the site. We’re using MariaDB here, but just like with the web server, there are other options that WordPress can use. Install MariaDB with the command:

sudo dnf install mariadb-server -y

Then, start and enable the database server to start on reboot with:

sudo systemctl enable --now mariadb

Creating the database

Next, we must create the database. Log into the MariaDB console with:

sudo mysql

Create the database with:


Create a new database user with:

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Where password is a strong, unique password. If you are hosting your database on another Rocky Linux instance, you’ll need to make sure that you grant the permissions to the web server’s IP address, instead of localhost.

Flush the privileges and exit the console with the following commands:


Installing and configuring PHP

We can now install PHP. This will also add php-fpm, which is a tool used to speed up website performance because it is faster than traditional CGI methods. As well, PHP uses php-fpm as its daemon. Before we can install PHP, we must add the EPEL repo with:

sudo dnf install epel-release -y

Install PHP 8.1 with:

sudo dnf module install php:8.1 -y

Install the required PHP packages with:

sudo dnf install php-fpm php-curl php-gd php-intl php-mbstring php-soap php-xml php-zip php-mysqli -y

Restart the php-fpm service with:

sudo systemctl restart php-fm

Configure NGINX

The next step is to create an NGINX configuration file. You'll use either your hostname or IP address for the name of the file. Create that file with:

sudo nano /etc/nginx/conf.d/

Where NAME is either your domain or IP address.

In that file, paste the following:

server {
server_name DOMAIN or IP;
    root /var/www/html/wordpress;
    index index.html index.htm index.nginx-debian.html index.php;

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

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

Make sure to change out DOMAIN or IP with either your domain or the IP address of your hosting server.

Save and close the file.

Download and extract WordPress

Change into the /tmp directory with

cd /tmp

Download the latest WordPress file with

sudo curl -LO

Extract the file with:

sudo tar xzvf latest.tar.gz -C /var/www/html/

Change into the new directory with

cd /var/www/html/wordpress

Copy the configuration file with

sudo cp wp-config-sample.php wp-config.php

Give the directory the necessary ownership with

sudo chown -R nginx:nginx /var/www/wordpress/

Configure WordPress

The first thing you must do is download unique secure values for WordPress with the official secret generator with the command:

sudo curl -s

Copy those values.

Open the wp-config.php file with

sudo nano wp-config.php

In that file, you'll find a section that looks like this:

define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');

Replace that section with the secret values generated by the WordPress secret generator. 

Next, locate the database definition section and replace the following values with the ones we created in the MariaDB console:

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

Save and close the file.

Enable the necessary ports in the firewall

We can now open our firewall to allow traffic through with the following commands:

sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --add-port=443/tcp --permanent
sudo firewall-cmd --reload

Finish the installation

Open a web browser and point it to http://SERVER (where SERVER is either the domain or IP address of the hosting server). You will be greeted by the WordPress installation page (Figure 1), where you can fill out the necessary information and click Install WordPress to complete the process.

Figure 1

The WordPress installation page is ready to guide you through the rest of the process.

And that's all there is to installing WordPress on Rocky Linux. Enjoy!

Related posts

2023 Holiday Gift Guide for Rocky Linux Users

2023 Holiday Gift Guide for Rocky Linux Users

Dec 19, 2023

Rocky Linux

Why Rocky Linux Is a Rock-Solid Choice in an Economic Downturn

Why Rocky Linux Is a Rock-Solid Choice in an Economic Downturn

Jan 18, 2023

Rocky Linux

6 Signs That It's Time to Move to Rocky Linux

6 Signs That It's Time to Move to Rocky Linux

Feb 23, 2023

Rocky Linux