RHEL BasedRocky Linux

How To Install WordPress on Rocky Linux 9

Install WordPress on Rocky Linux 9

In this tutorial, we will show you how to install WordPress on Rocky Linux 9. WordPress, the world’s most popular content management system, powers over 40% of all websites on the internet. Its flexibility, user-friendly interface, and vast ecosystem of themes and plugins make it an excellent choice for bloggers, businesses, and developers alike. If you’re looking to harness the power of WordPress on a robust and stable operating system, Rocky Linux 9 is an excellent choice. In this comprehensive guide, we’ll walk you through the process of installing WordPress on Rocky Linux 9, step by step.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything you need to get started:

  • A Rocky Linux 9 server with root or sudo access
  • A domain name pointed to your server’s IP address
  • Basic familiarity with the command line interface
  • At least 1GB of RAM (2GB or more recommended)
  • Minimum 10GB of free disk space

Step 1: Update System Packages

Before we begin the installation process, it’s crucial to ensure your Rocky Linux 9 system is up to date. This step helps prevent potential conflicts and ensures you have the latest security patches.

Open your terminal and run the following command:

sudo dnf update -y

This command will update all installed packages to their latest versions. The “-y” flag automatically answers “yes” to any prompts, streamlining the update process.

Step 2: Install Apache Web Server

Apache is one of the most popular web servers and is well-suited for hosting WordPress. Let’s install and configure Apache on your Rocky Linux 9 system.

To install Apache, run:

sudo dnf install httpd -y

Once the installation is complete, start the Apache service and enable it to run at boot:

sudo systemctl start httpd
sudo systemctl enable httpd

To verify that Apache is running correctly, open a web browser and navigate to your server’s IP address. You should see the default Apache test page.

Step 3: Install MariaDB Database Server

WordPress requires a database to store its content and settings. MariaDB, a fork of MySQL, is an excellent choice for Rocky Linux 9. Let’s install and secure MariaDB.

Install MariaDB with the following command:

sudo dnf install mariadb-server mariadb -y

Start the MariaDB service and enable it to run at boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

To secure your MariaDB installation, run the mysql_secure_installation script:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove the test database.

Now, let’s create a database and user for WordPress:

sudo mysql -u root -p

Enter your MariaDB root password when prompted. Then, run the following SQL commands:

CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Remember to replace ‘your_strong_password’ with a secure password of your choice.

Step 4: Install PHP and Required Extensions

PHP is the programming language that WordPress is built on. We need to install PHP and several extensions to ensure WordPress functions correctly.

Install PHP and the necessary extensions with this command:

sudo dnf install php php-mysqlnd php-fpm php-gd php-mbstring php-xml php-json -y

After the installation is complete, restart Apache to load the PHP module:

sudo systemctl restart httpd

To verify that PHP is working correctly, create a test file:

sudo echo "" > /var/www/html/info.php

Now, visit http://your_server_ip/info.php in your web browser. If you see a page with PHP information, the installation was successful. For security reasons, remember to remove this file after testing:

sudo rm /var/www/html/info.php

Step 5: Configure Firewall Settings

To allow web traffic to reach your server, you need to configure the firewall to permit HTTP and HTTPS connections.

Open the necessary ports with these commands:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

These commands open ports 80 (HTTP) and 443 (HTTPS) in the firewall, allowing web traffic to reach your Apache server.

Step 6: Download and Extract WordPress

Now that we have our LAMP stack set up, it’s time to download and set up WordPress.

First, navigate to the Apache web root directory:

cd /var/www/html

Download the latest version of WordPress:

sudo wget https://wordpress.org/latest.tar.gz

Extract the downloaded archive:

sudo tar -xzvf latest.tar.gz

Set the correct ownership and permissions:

sudo chown -R apache:apache wordpress
sudo chmod -R 755 wordpress

Step 7: Configure Apache for WordPress

To serve WordPress, we need to create a virtual host configuration file for Apache.

Create a new configuration file:

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

Add the following content to the file:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/html/wordpress
    ServerName example.com

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

    ErrorLog /var/log/httpd/wordpress_error.log
    CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>

Replace “example.com” with your domain name. Save and close the file.

Restart Apache to apply the changes:

sudo systemctl restart httpd

Step 8: Complete the WordPress Installation via Browser

With all the backend configuration complete, we can now finish the WordPress installation through the web interface.

Open your web browser and navigate to http://your_domain_or_IP. You should see the WordPress setup page.

Follow these steps to complete the installation:

1. Choose your language and click “Continue”.
2. On the next page, click “Let’s go!”.
3. Enter the database information we set up earlier:
– Database Name: wordpress
– Username: wpuser
– Password: (the password you set earlier)
– Database Host: localhost
– Table Prefix: wp_ (you can change this for security reasons)
4. Click “Submit” and then “Run the installation”.
5. Fill in the site information:
– Site Title
– Username (for admin access)
– Password
– Your Email
6. Click “Install WordPress”.

Congratulations! You’ve successfully installed WordPress on Rocky Linux 9.

Install WordPress on Rocky Linux 9

Troubleshooting Common Issues

Even with careful following of instructions, you might encounter some issues. Here are solutions to common problems:

Permission Errors

If you encounter permission errors, ensure that the Apache user has the correct permissions:

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

Database Connection Issues

If WordPress can’t connect to the database, double-check your database credentials in the wp-config.php file:

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

Ensure the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST values are correct.

SELinux-Related Problems

If you’re experiencing unexpected behavior, SELinux might be the culprit. You can temporarily disable SELinux to test:

sudo setenforce 0

If this resolves the issue, you may need to configure SELinux policies for WordPress. To re-enable SELinux:

sudo setenforce 1

Congratulations! You have successfully installed WordPress. Thanks for using this tutorial to install the latest version of WordPress on Rocky Linux 9. For additional help or useful information, we recommend you check the official WordPress website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button