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

Install WordPress Rocky Linux LAMP Apache

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.

Prerequisites:

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

Notes:

  1. Replace tonys.surf 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 tonys.surf to the IP address of your server
  • Point www.tonys.surf 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 https://wordpress.org/latest.tar.gz --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>
    ServerName tonys.surf
    ServerAlias www.tonys.surf
    DocumentRoot /var/www/wordpress
    <Directory "/var/www/wordpress">
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
    ErrorLog /var/log/httpd/wordpress_error.log
    CustomLog /var/log/httpd/wordpress_access.log common
</VirtualHost>

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;
exit

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 wordpress

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 file

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_failed

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 setup

Upon completion of the installation, you can access your WordPress administrator dashboard at http://tonys.store/wp-admin/

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.

Facebook
Twitter
Pinterest
LinkedIn
Reddit

Meet Tony

Tony Teaches Tech headshot

With a strong background in computer science and enterprise web development, 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 Reply

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