WordPress is one of the most popular content management systems (CMS) in the world, powering millions of websites. Installing WordPress on Red Hat Linux 9 (RHEL 9) allows businesses and developers to build flexible, secure, and scalable websites on a robust dedicated Linux server environment.
In this guide, Go4hosting will walk you through the step-by-step process of installing WordPress on a fresh Red Hat Enterprise Linux 9 server. We will cover all necessary prerequisites including setting up a web server, database, PHP, and configuring WordPress itself.
Prerequisites
Before starting the installation, make sure you have:
A Red Hat Enterprise Linux 9 server instance (either bare metal or cloud VPS hosting).
A user account with sudo privileges.
An active internet connection to download required packages.
A registered domain name (optional but recommended for production).
Basic familiarity with the Linux command line.
Step 1: Update Your System
First, update your system packages to the latest versions:
bash
CopyEdit
sudo dnf update -y
This ensures all security patches and dependencies are current.
Step 2: Install Apache Web Server
WordPress requires a web server feature to serve the website files. Apache is a popular choice:
bash
CopyEdit
sudo dnf install httpd -y
Start and enable Apache to run on boot:
bash
CopyEdit
sudo systemctl start httpd
sudo systemctl enable httpd
Check the status to confirm it is running:
bash
CopyEdit
sudo systemctl status httpd
You should also configure the firewall to allow HTTP and HTTPS traffic:
bash
CopyEdit
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 3: Install MariaDB (MySQL Compatible Database)
WordPress stores content and configuration in a database. MariaDB is the default database server in RHEL:
bash
CopyEdit
sudo dnf install mariadb-server mariadb -y
Start and enable MariaDB:
bash
CopyEdit
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure your MariaDB installation by running:
bash
CopyEdit
sudo mysql_secure_installation
Follow the prompts to:
Step 4: Create a WordPress Database and User
Log in to the MariaDB shell:
bash
CopyEdit
sudo mysql -u root -p
Create a database for WordPress (replace wp_database with your preferred name):
sql
CopyEdit
CREATE DATABASE wp_database DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Create a dedicated WordPress user and grant privileges (replace wp_user and strong_password):
sql
CopyEdit
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Install PHP and Required Extensions
WordPress is written in PHP, so you need to install PHP and some extensions:
bash
CopyEdit
sudo dnf install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-json php-curl php-intl -y
Restart Apache to load PHP modules:
bash
CopyEdit
sudo systemctl restart httpd
Check the installed PHP version:
bash
CopyEdit
php -v
Step 6: Download and Configure WordPress
Navigate to the /var/www/html directory:
bash
CopyEdit
cd /var/www/html
Download the latest WordPress package:
bash
CopyEdit
sudo curl -O https://wordpress.org/latest.tar.gz
Extract the contents:
bash
CopyEdit
sudo tar -xzvf latest.tar.gz
This will create a wordpress directory. Move its contents to /var/www/html:
bash
CopyEdit
sudo rsync -av wordpress/ .
Remove the now-empty wordpress folder and the archive:
bash
CopyEdit
sudo rm -rf wordpress latest.tar.gz
Step 7: Set Correct Permissions
Set ownership of the WordPress files to the Apache user:
bash
CopyEdit
sudo chown -R apache:apache /var/www/html/*
Set appropriate permissions:
bash
CopyEdit
sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;
Step 8: Configure WordPress
Copy the sample configuration file:
bash
CopyEdit
sudo cp wp-config-sample.php wp-config.php
Edit wp-config.php with your database details:
bash
CopyEdit
sudo nano wp-config.php
Modify the following lines with your database name, user, and password:
php
CopyEdit
define('DB_NAME', 'wp_database');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'strong_password');
define('DB_HOST', 'localhost');
Optionally, generate new security keys for authentication. Visit the WordPress secret key generator and replace the key section in wp-config.php with the generated values.
Save and exit the editor.
Step 9: Adjust SELinux Settings (if enabled)
RHEL 9 enables SELinux by default, which can restrict Apache's ability to read and write files.
Allow Apache to serve files and write to the WordPress directory:
bash
CopyEdit
sudo setsebool -P httpd_unified 1
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html
Step 10: Complete WordPress Installation via Web Interface
Open your browser and navigate to:
arduino
CopyEdit
http://your-server-ip/
Or if you have a domain name pointing to your server:
arduino
CopyEdit
http://your-domain.com/
You will see the WordPress setup wizard:
Select your language.
Enter Site Title, Username, Password, and Email.
Click Install WordPress.
Once installation completes, log in with your admin credentials.
Step 11: Additional Recommendations
Enable HTTPS: Secure your website by installing an SSL certificate via Let's Encrypt or another provider.
Optimize PHP-FPM: If your setup uses PHP-FPM, ensure it is properly configured for performance.
Backups: Schedule regular backups of your WordPress files and database.
Updates: Keep WordPress core, plugins, and themes up-to-date for security and functionality.
Conclusion
Installing WordPress on Red Hat Linux 9 involves setting up a complete LAMP stack (Linux, Apache, MariaDB, PHP), configuring WordPress files, and securing your environment.
At Go4hosting, we offer optimized Red Hat Linux 9 free cloud servers with ready-to-go LAMP stacks and expert support to help you deploy WordPress and other web applications quickly and securely.
If you need assistance or want to host your WordPress site on a reliable cloud platform, get in touch with Go4hosting today!