Setting Up WordPress on Centos 7 (With External DB) - blake-anderson/SEC-440 GitHub Wiki

Installing LAMP Stack with an external maria-db cluster

Install Apache

yum install httpd

Install PHP 7.2

Install repositories-

yum install epel-release yum-utils

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager --enable remi-php72

yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd

Create Database on Remote MariaDB

Note- This guide is the second step to guide- https://github.com/blake-anderson/SEC-440/wiki/Creating-a-HA-MySQL-Cluster-with-MariaDB-Galera

This means the database is external, and is a cluster of actively synced DB instances.

On the master node-

mysql -u root -p

CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

FLUSH PRIVILEGES;

EXIT;

Note: This database should now show up across all three nodes if the command SHOW DATABASES; is used in MySQL.

Install MariaDB Client on Webserver

To add the repo, run the following-

cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

EOF

Once this is done, yum install mariadb-client

Install Wordpress

cd /tmp && wget http://wordpress.org/latest.tar.gz

tar -xvzf latest.tar.gz -C /var/www/html

cd /var/www/html/wordpress

chown -R apache /var/www/html/wordpress

Configure Apache

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

Add the text found in the repo of this Github Page- https://github.com/blake-anderson/SEC-440/blob/master/wordpress.conf

SELinux

As it turns out, SELinux does not like playing nice with the external databases. Due to the difficulty in figuring out where it is breaking, turn off SELinux (nano /etc/selinux/config, change line SELINUX=enforcing to disabled. Reboot the server.

Repeat Everything on Web Server 2, Minus the Remote Database Change

WordPress Configuration File

mv /var/www/html/wordpress/wp-sample-config.php /var/www/html/wordpress/wp-sample-config.php

In this file, change the following lines with the appropriate database info-

define( 'DB_NAME', 'wordpress' );

/** MySQL database username */

define( 'DB_USER', 'wordpressuser' );

/** MySQL database password */

define( 'DB_PASSWORD', 'password' );

/** MySQL hostname */

define( 'DB_HOST', '10.0.5.55' );

NOTE: Make sure the MySQL hostname points to the Virtual IP address of the cluster that was setup with keepalived!

Once this is done, navigate to the webserver IP, and you should see the initial setup page for WordPress!