Install WordPress on Rocky Linux 9 with Apache

Rocky Linux 9 is a powerful operating system designed for servers, particularly in the realm of web hosting and server management. In this tutorial, we’ll walk through the process of installing WordPress on Rocky Linux 9 using the Apache web server. WordPress is a popular content management system (CMS) that allows users to create and manage websites with ease. By combining Rocky Linux’s stability and security with the versatility of WordPress and Apache, you can create a robust and dynamic web presence for your projects or business. Let’s dive into the steps to set up WordPress on Rocky Linux 9 with Apache.

Tutorial Environment

In this tutorial, we will work with the following server, operating system, and software:

  • Vultr Cloud Server: 1 CPU, 1 GB RAM, 32 GB Storage
  • Operating System: Rocky Linux 9
  • Domain: aminlabs.my.id
  • SSL: Let’s Encrypt
  • Web Server: Apache v2.4.57
  • PHP: PHP v8.2
  • Database: MariaDB v10.5
  • WordPress: WordPress v6.4.3

Note: Register here to get $100 free credit from Vultr.

Step 1: Update system packages

Connect to your server and ensure your system packages are up-to-date:

Note: This tutorial uses the root user.

Step 2: Install Apache web server

Execute the following command to install the Apache web server:

After the installation is complete, start the Apache service and enable it to start on boot:

You can verify the Apache service status to ensure it’s running without any issues:

Open HTTP and HTTPS ports in firewall, execute the following commands:

Step 3: Configure Virtual Host

Create the directory for aminlabs.my.id:

Create a virtual host configuration for the domain aminlabs.my.id:

Insert the following virtual host configuration:

Restart the Apache service to reload configuration:

Step 4: Install SSL from Let’s Encrypt

Let’s Encrypt is a free, automated, and open certificate authority that provides digital certificates for enabling HTTPS (SSL/TLS) on websites. It was launched in 2015 by the Internet Security Research Group (ISRG) with the aim of making it easier for website owners to secure their websites with HTTPS. Let’s Encrypt certificates are trusted by all major browsers and are valid for 90 days, after which they can be renewed automatically.

Install Certbot and the Apache web server plugin:

Request an SSL certificate for aminlabs.my.id and www.aminlabs.my.id. The email address is used to send notifications when the SSL certificate is about to expire.

Example message displayed when the SSL certificate request is successful:

Step 5: Install MariaDB database

Install MariaDB server using the following command:

Start the MariaDB service and enable it to start on boot:

Step 6: Create a Database

Log in to MariaDB server:

Create a MariaDB database for WordPress:

Step 7: Install PHP 8.2

To install PHP 8.2 on Rocky Linux 9, you need to add the EPEL repository and the REMI repository to your system. These repositories provide additional packages, including newer versions of PHP that are not available in the default Rocky Linux repositories.

EPEL (Extra Packages for Enterprise Linux) repository provides additional packages for CentOS and its derivatives like Rocky Linux. Install the EPEL repository using the following command:

REMI repository provides updated versions of various software packages, including PHP, that are not available in the default repositories. Install the REMI repository by executing the following commands:

Once you have installed the REMI repository, enable the PHP 8.2 repository:

Now, you can install PHP 8.2 and the required PHP modules:

Create a symbolic link for php82:

Start the PHP-FPM service and enable it to start on boot:

Restart the Apache service:

Step 8: Install WordPress via WP-CLI

WP-CLI (WordPress Command Line Interface) is a powerful tool for managing WordPress installations from the command line. It provides a convenient and efficient way to perform various tasks such as installing, updating, and managing WordPress sites without needing to use a web browser.

With WP-CLI, you can automate WordPress tasks, script complex operations, and interact with your WordPress site’s database directly from the command line interface. This makes it an indispensable tool for developers, system administrators, and anyone who manages multiple WordPress sites.

Begin by installing WP-CLI on your server. You can download the Phar file and make it executable for global use:

Navigate to document root directory:

Download the latest WordPress core files using WP-CLI:

Generate the wp-config.php file using WP-CLI and provide the necessary database information:

Install WordPress and create an admin account:

The message displayed when WordPress installation is successful:

Change the user and group of the WordPress files to the user and group of the Apache web server:

The WordPress installation process has been completed. Browse the domain to try the installation result.

If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!

Donate via PayPal: https://paypal.me/musaamin

Leave a Reply

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