AWS Hands-On Lab WordPress using RDS and EC2 for Cloud/DevOps Engineers

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

  1. In the AWS management console, enter "RDS" into the search bar on top.

  2. From the results, select RDS.

  3. Click Create database.

  4. 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.

  1. While the database is created, navigate to "EC2" in the search bar on top.

  2. Under Resources, click Instances (running).

  3. Click connect to your EC2 instance used on the previous hands-on lab for AWS EC2 Instance Bootstrapping.

📝Install Apache and Dependencies

  1. In the terminal, install the Apache web server, libraries, PHP, and PHP MySQL:

     sudo apt install apache libapache-mod-php php-mysql -y
    
  2. Go into to /var/www directory and view the contents of the directory:

     cd /var/www
     ls
    
  3. 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 the wordpress directory:

     sudo mv /wordpress .
     ls
     cd wordpress
    
  4. 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/
    
  5. Restart the Apache configuration:

     sudo apachectl restart
    
  6. Open the WordPress config PHP file for editing:

     sudo nano wp-config.php
    
  7. Return to the browser window or tab that has the RDS Databases open, and click the wordpress database.

  8. In the Connectivity & security tab, under Endpoint, copy the endpoint provided into your clipboard.

  9. 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
    
  10. Save and exit by pressing Control + X, followed by Y, and hitting Enter.

📝Modify Security Groups

  1. Return to your browser window or tab with the EC2 Connect to instance page open.

  2. In the left-hand navigation menu, under Networks & Security, click Security Groups your usual security group.

  3. Click the Inbound rules tab, and the Edit inbound rules button.

  4. Click the Add rule button, and from the Type dropdown menu, select MYSQL/Aurora.

  5. 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

  1. Return to the EC2 management console.

  2. Copy the public IP and paste it to a new browser window.

  3. 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"

  1. Click Install WordPress and click Log in.

  2. Enter the Username and Password set by you.

  3. 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