AWS Hands-On Lab WordPress using RDS and EC2 for Cloud/DevOps Engineers
AWS Learning Path for Cloud and DevOps Engineers
📝Introduction
This post covers an introduction to creating an RDS database, installing a web server and configuring a WordPress website to connect to the RDS database.
📝Log in to the AWS Management Console
Using your credentials, make sure you're using the right Region. In my case, I chose us-east-1
.
Note: For this lab, we will need to use only the same EC2 instance type without any app install, used in our previous hands-on lab for AWS EC2 Instance Bootstrapping.
📝Create RDS Database Instance
In the AWS management console, enter "RDS" into the search bar on top.
From the results, select RDS.
Click Create database.
On the Create database page, set the following parameters:
Select Standard create.
Under Engine options, select MySQL.
Select Version: MySQL 8.0.33.
Under Templates, select Free tier.
Under DB instance identifier, enter "wordpress" and copy this into your clipboard.
Use "wordpress" as the username and the password.
Under DB instance class, select db.t2.micro.
Under Connectivity, select the existing VPC and leave the Don't connect to an EC2 compute resource selected.
Under the VPC security group, select your usual security group from the dropdown menu and remove the default security group.
Under Availability zone, select
<your-region>
.Expand Additional configuration and, under Initial database name, enter "wordpress".
Under Backups, uncheck the Enable automatic backups option.
Leave the other settings as default and click Create database.
While the database is created, navigate to "EC2" in the search bar on top.
Under Resources, click Instances (running).
Click connect to your EC2 instance used on the previous hands-on lab for AWS EC2 Instance Bootstrapping.
📝Install Apache and Dependencies
In the terminal, install the Apache web server, libraries, PHP, and PHP MySQL:
sudo apt install apache libapache-mod-php php-mysql -y
Go into to
/var/www
directory and view the contents of the directory:cd /var/www ls
Put
wordpress
into its own folder in the/var/www
the directory that we're currently in, view the content of the directory again and go into thewordpress
directory:sudo mv /wordpress . ls cd wordpress
Move the Apache configuration file into
/etc/apache/sites-enabled/
to enable the WordPress website to work from/var/www/wordpress
:sudo mv 000-default.conf /etc/apache/sites-enabled/
Restart the Apache configuration:
sudo apachectl restart
Open the WordPress config PHP file for editing:
sudo nano wp-config.php
Return to the browser window or tab that has the RDS Databases open, and click the wordpress database.
In the Connectivity & security tab, under Endpoint, copy the endpoint provided into your clipboard.
Please, return to the terminal of EC2 instance, and change the line:
define('DB_HOST', 'localhost'); Old entry define('DB_HOST', '<INSERT ENDPOINT HERE>'); New entry
Save and exit by pressing Control + X, followed by Y, and hitting Enter.
📝Modify Security Groups
Return to your browser window or tab with the EC2 Connect to instance page open.
In the left-hand navigation menu, under
Networks & Security
, clickSecurity Groups
your usual security group.Click the Inbound rules tab, and the Edit inbound rules button.
Click the Add rule button, and from the Type dropdown menu, select MYSQL/Aurora.
In the dropdown menu to the right of the Source column for the new rule, find and select your usual security group, and click Save rules.
📝Complete Wordpress Installation and Test
Return to the EC2 management console.
Copy the public IP and paste it to a new browser window.
The WordPress installation page will launch and then enter the following information for each field:
Site Title:
<enter-a-name>
Username:
<enter-a-name>
Password: Select a strong password to use here, and make sure to copy it to your clipboard for later.
Your Email: "test@test.com"
Click Install WordPress and click Log in.
Enter the Username and Password set by you.
To check the result, confirm if you can see the same Site Title given by you in the top right corner of the page.
Congratulations — you have completed this hands-on lab covering the basic introduction to creating an RDS database, installing a web server and configuring a WordPress website to connect to the RDS database.
Thank you for reading. I hope you were able to understand and learn something helpful from my blog.
Please follow me on CloudDevOpsToLearn and on LinkedIn franciscojblsouza