Project 3 - CameronProvost/SEC440 GitHub Wiki

Web Application and Database Redundancy

U1, U2 & U3 Configuration

Sudo adduser cameron
Sudo usermod -aG sudo cameron
Sudo hostnamectl set-hostname u1-cameron
Sudo nano /etc/netplan/00-installer-config.yaml

U1

u1 net

U2

u2 net

U3

Sudo netplan apply
Reboot

Galera Installion and Configuration

sudo apt update
sudo apt install mariadb-server mariadb-client galera-4 rsync -y

sudo systemctl enable mariadb
sudo systemctl start mariadb

sudo nano /etc/mysql/mariadb.conf.d/60-galera.cnf

U1

u1gal

U2

u2gal

U3

u3gal

Firewall Rules

sudo ufw allow 3306/tcp      # MySQL/MariaDB
sudo ufw allow 4444/tcp      # Galera replication
sudo ufw allow 4567/tcp      # Galera communication
sudo ufw allow 4568/tcp      # Galera IST (incremental state transfer)
sudo ufw allow 22/tcp        # SSH
sudo ufw reload

Initialize The Cluster

On U1

sudo systemctl stop mariadb
sudo galera_new_cluster

On U2 & U3

sudo systemctl stop mariadb
sudo systemctl start mariadb

Test Cluster

Sudo mysql -u root -p 

Show status like ‘wsrep_cluser_size’;

glaisowrking

Secure The Databases

sudo mysql_secure_installation

Installing Wordpress

sudo dnf install httpd php php-mysqlnd php-fpm wget unzip -y

Configure Wordpress On Web01 and Web02

cd /var/www/html
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo chown -R apache:apache /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
sudo mv wordpress/* /var/www/html/

Create Wordpress Database and User

On U1

mysql -u root -p
CREATE DATABASE wordpress_db;
CREATE USER 'cameron_wp'@'%' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'cameron_wp'@'%';
FLUSH PRIVILEGES;

Wordpress Configuration on Web01 and Web02

cd /var/www/html
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Make the following changes to wp-config.php

define( 'DB_NAME', 'wordpress_db' );
define( 'DB_USER', 'cameron_wp' );
define( 'DB_PASSWORD', 'your_secure_password' );
define( 'DB_HOST', '10.0.6.10' );

Create Virtual Host Configuration

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

Add the following:

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName 10.0.6.10
    <Directory /var/www/html>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
sudo systemctl restart httpd

SELLinux

sudo setsebool -P httpd_can_network_connect_db 1

Complete the rest of wordpress installaion from Xubuntu-Wan's web Browser by navigating to http://10.0.6.10

⚠️ **GitHub.com Fallback** ⚠️