Some requirements before you start:
1. Makes sure you have RHEL 7
2. Please note that this script turns off the firewall, so unless for testing you will need to open up the ports
3. I assume that you have selinux= permissive, else some of the packages will not get downloaded properly.
4 Run the below as a bash script for example make the file executable with chmod +x <fileName>.sh

#!/bin/bash

# This script will download, configure and install WordPress for RHEL 7.x Linux.

 

# Make sure RHEL is pointing to the right repo

subscription-manager attach –auto

# Stop the firewall ..test only

systemctl stop firewalld.service

 

#echo ‘Install the database and prerequisites’

yum -y install mariadb-server httpd php php-mysql

#start the DB services

systemctl enable mariadb.service

systemctl start mariadb.service

 

#echo ‘Add to the database’

echo ‘CREATE DATABASE wordpress;’ | mysql

echo “GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpress’@’localhost’ IDENTIFIED BY ‘nothing123’;” | mysql

echo “FLUSH PRIVILEGES;” | mysql

#echo ‘Download and install WordPress’

wget –no-check-certificate http://wordpress.org/latest.tar.gz

tar -C /var/www/html/ –strip-components=1 -zxvf latest.tar.gz && rm -f latest.tar.gz

cd /var/www/html

mkdir wp-content/{uploads,cache}

chown apache:apache wp-content/{uploads,cache}

chmod 777 /var/www/html/wp-content

 

#echo ‘Configure WordPress’

cp wp-config-sample.php wp-config.php

sed -i ‘s@database_name_here@wordpress@’ wp-config.php

sed -i ‘s@username_here@wordpress@’ wp-config.php

sed -i ‘s@password_here@nothing123@’ wp-config.php

curl -k https://api.wordpress.org/secret-key/1.1/salt/ >> wp-config.php

 

#Restart httpd service

systemctl enable httpd.service

systemctl start httpd.service