How To Install WordPress on Rocky Linux (Apache LAMP server)


Hey there! Some links on this page may be affiliate links which means that, if you choose to make a purchase, I may earn a small commission at no extra cost to you. I greatly appreciate your support!

In this tutorial, learn how to install a WordPress website with a domain name on a Rocky Linux server running a LAMP stack with Apache.


  • Rocky Linux LAMP server (follow this tutorial if you don’t have one)
  • Domain name


  1. Replace with the name of your domain name in this tutorial
  2. A complete video tutorial is available at the end of this tutorial

1. Point Domain Name at Server

Login to wherever you bought your domain name, find the DNS settings, and create two A records:

  • Point to the IP address of your server
  • Point to the IP address of your server

If you need more help setting up your A records, check out this video.

2. Download WordPress

Download and extract the official WordPress package to the web directory of your Rocky Linux server, and apply the appropriate permissions.

cd /var/www/
curl --output wordpress.tar.gz
tar xf wordpress.tar.gz
rm wordpress.tar.gz
chown -R nginx:nginx /var/www/wordpress
find /var/www/wordpress -type d -exec chmod 755 {} \;
find /var/www/wordpress -type f -exec chmod 644 {} \;

3. Configure the Apache Web Server

Create a file called wordpress.conf in the /etc/httpd/conf.d/ directory with the following content. Replace the ServerName and ServerAlias with your own.

<VirtualHost *:80>
    DocumentRoot /var/www/wordpress
    <Directory "/var/www/wordpress">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    ErrorLog /var/log/httpd/wordpress_error.log
    CustomLog /var/log/httpd/wordpress_access.log common

Apply this change by restarting the web server.

systemctl restart httpd
systemctl status httpd

3. Setup the WordPress Database

Access the MySQL command prompt.

mysql -u root -p

Create an empty database for WordPress.

create database db_name;
create user 'example_db'@'localhost' identified by 'example_pw';
grant all privileges on example_db.* TO 'example_uer'@'localhost';
flush privileges;

4. Install Additional PHP Modules

When you navigate to your website in a web browser, you will see an error that says:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.


your php installation appears to be missing the mysql extension which is required by wordpressPin

To fix this error, use the dnf package manager to install this required MySQL extension in addition to other PHP modules recommended by WordPress.

dnf install php-mysqlnd php-gd php-json php-mbstring php-pecl-zip php-xml php-imagick

5. Allow Apache to Work with SELinux

You must explicitly change the SELinux security context of the WordPress directory to avoid the wp-config.php write error message during the installation of WordPress.

Unable to write to wp-config.php file.

Unable to write to wp-config.php filePin

To change the SELinux security context, execute the following chcon command.

chcon -R -t httpd_sys_rw_content_t /var/www/wordpress/

You must also tell SELinux to allow web server scripts and modules to connect to the network to avoid cURL error 7.

Error: cURL error 7: (http_request_failed)

curl error 7 http_request_failedPin

Once you have WordPress installed (after the next step), you can check your site’s status from the WordPress administrator dashboard under Tools > Site Health.

To change this SELinux setting, execute the following sesetbool command.

setsebool httpd_can_network_connect true

6. Finish WordPress Install

You can now access your website via your domain name in a web browser. You will be prompted to finish the WordPress installation, part of which is entering the database name, user, and password that you created earlier.

WordPress database setupPin

Upon completion of the installation, you can access your WordPress administrator dashboard at

YouTube video

Next Steps

Now that you have a fresh install of WordPress, check out 15 important things to do after installing WordPress which includes installing an SSL certificate for a secure HTTPS website.

Meet Tony

With a strong software engineering background, Tony is determined to demystify the web. Discover why Tony quit his job to pursue this mission. You can join the Tony Teaches Tech community here.

Leave a Comment

The reCAPTCHA verification period has expired. Please reload the page.