Installing WordPress on Rocky Linux and AlmaLinux involves setting up a LAMP (Linux, Apache, MySQL, PHP) stack and configuring WordPress. Below is a step-by-step guide to help you with the installation process.

Step 1: Set Up a LAMP Stack

Install Apache:

sudo dnf install httpd
sudo systemctl start httpd
sudo systemctl enable httpd

Install MariaDB (MySQL):

sudo dnf install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation

Follow the prompts to secure your MariaDB installation.

Install PHP:

sudo dnf install php php-mysqlnd php-json php-gd php-mbstring
sudo systemctl restart httpd

Step 2: Create a Database for WordPress

Log in to MariaDB:

sudo mysql -u root -p

Create a database, a user, and grant privileges:

CREATE DATABASE wordpressdb;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Download and Configure WordPress

Download WordPress:

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
sudo mv wordpress /var/www/html/

Configure WordPress:

sudo chown -R apache:apache /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

Step 4: Set Up Apache Virtual Host

Create a new virtual host configuration file:

sudo nano /etc/httpd/conf.d/wordpress.conf

Add the following configuration:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/html/wordpress
    ServerName your_domain.com
    ErrorLog /var/log/httpd/wordpress_error.log
    CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>

Save the file and restart Apache:

sudo systemctl restart httpd

Step 5: Complete WordPress Installation

Open your web browser and navigate to your server’s domain or IP address. Follow the on-screen instructions to complete the WordPress installation.

Step 6: Secure Your WordPress Installation

Update WordPress Configuration:

sudo nano /var/www/html/wordpress/wp-config.php

Add the database details you created earlier:

define('DB_NAME', 'wordpressdb');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'your_password');

Save and close the file.

Set File Permissions:

sudo chown -R apache:apache /var/www/html/wordpress
sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;

Step 7: Enable Pretty Permalinks (Optional)

In the WordPress dashboard, go to “Settings” > “Permalinks” and choose a permalink structure. This step is optional but improves the appearance and search engine optimization of your site.

Conclusion:

You’ve successfully installed WordPress on Rocky Linux or AlmaLinux. Regularly update WordPress, plugins, and themes to ensure security. Enjoy building your website with WordPress!

Last Update: December 9, 2023