???? Ready to elevate your online presence? Explore the art of effortlessly setting up WordPress on Amazon EC2 paired with the robust Amazon RDS MySQL database. This interactive guide unravels the potential of Amazon’s cloud services, promising a website that is not only high-performance but also scalable. Before we dive into the nitty-gritty, let’s acquaint ourselves with the superheroes of this hosting adventure.
Meet our Superheroes????:
Amazon RDS :
???? Amazon RDS is not just a database service; it’s a high-performance Relational Database Service. Revel in features like Multi-AZ and Read Replica, ensuring unmatched data availability.
????Supporting various database engines such as MySQL, Amazon Aurora, PostgreSQL, MariaDB, Oracle Database, IBM’s DB2, and SQL Server, RDS empowers your website with unprecedented scalability and reliability.
????It allows you to select different instance types based on your workload requirements. You can choose between different combinations of CPU, memory, and storage to optimize performance and cost???? for your database workload
Apache Server:
???? Enter Apache HTTP Server, the undisputed choice for hosting WordPress websites. This stalwart ensures seamless content delivery by handling HTTP requests and serving web pages, adding to the stability and versatility of your website.
WordPress:
???? Unleash the potential of WordPress, an open-source content management system (CMS) crafted in PHP and supported by databases like MariaDB. This user-friendly platform empowers you to manage, create, and publish web content effortlessly.
Now, armed with the knowledge of these superheroes, let’s embark on a step-by-step journey to transform your web hosting experience. Are you ready to witness the synergy of Amazon EC2 and RDS MySQL in action? Let’s dive in!
Architecture Diagram
- Create Security groups for EC2 and RDS.
- Create a RDS DB Instance.
- Launch an EC2 Instance.
- Install WordPress application.
- Log in and test the WordPress application.
1. Navigate to EC2 by clicking on the Services menu, under the Compute section.
2. On the left panel menu, select the security group under the Network & Security section.
1. Click on Create Security Group.
2. We are going to create a Security group for EC2 with port numbers 22 for SSH and 80 for HTTP enabled.
o Security group name : Enter MyWordPress_SG
o Description: Enter Allows SSH and HTTP access
o VPC: Select Default VPC
3. Click on the Add Rule button under Inbound rules.
To add SSH,
· Type: Select SSH
· Source: Select Custom, in the textbox add 0.0.0.0/0
For HTTP, Click on Add Rule
· Choose Type: HTTP
· Source: Select Custom, in the textbox add 0.0.0.0/0
4. Leave everything as default and click on Create Security Group.
1. Create a Security group for RDS and configure it to allow incoming database connections from the EC2 Instance.
· Security group name : Enter MyRDS_SG
· Description: Enter Allows database access
· VPC: Select Default VPC
· Click on the Add Rule button under Inbound rules.
???? Type: Select MySQL/Aurora
???? Source: Select Custom
???? In the textbox, type Mywor and select MyWordPress_SG as shown in the below screenshot.
???? This means the RDS security group is allowing inbound access from the EC2 security group only.
2. Leave everything as default and click on Create Security Group.
1. Navigate to the Services menu at the top left corner and click on RDS present under the Database section.
2. Click on Create Database.
3. On the Create database page, verify that the Standard create option is chosen. Then choose MySQL in the Engine type.
4. Other fields, Leave it as default
5. In the Templates section, choose Dev/Test.
6. Under Availability and durability, select Single DB instance
7. Under Settings, provide the following details.
· DB cluster identifier: Enter wordpress-db-1
· Master username : Enter admin
· Master password : Enter Password as per your choice
· Confirm password : Enter the password typed in the previous step.
8. Under DB instance class, select Burstable classes (including t classes) and select db.t3.micro
9. Under Storage:
· Storage type: General Purpose SSD (gp2)
· Allocate storage: 20 GiB
· Uncheck Enable storage autoscaling.
10. Under Connectivity: Network & Security
· Virtual Private Cloud (VPC): default VPC
· Subnet group: default
· Public accessibility: Choose No, as database shouldn’t be accessible to public.
· VPC security groups: Select Choose existing. Remove the default one and select MyRDS_SG instead.
11. Leave Database Authentication as default.
12. Expand the Additional configuration.
13. In the displayed layout provide the following values under Database options.
· Initial database name : Enter wordpress_db
Important: Make sure you note down the database name as we will use it in WordPress.
· Leave DB parameter group and Option group as default.
· Under Backup, uncheck Enable automatic backups.
· Under Encryption, uncheck Enable encryption.
· Leave other settings as default.
· Make sure Deletion protection is unchecked.
14. Click on Create Database to create the database. It takes time between 5–10 minutes.
15. Once the database is created the status changes to Available as shown in the below screenshot.
16. Click on the created RDS instance and note down the Endpoint under the Connectivity and security tab. The details you have noted will be used for later purpose.
1. Navigate to EC2 by clicking on the Services menu in the top left, then click on EC2 in the Compute section.
2. Navigate to Instances from the left side menu and click on Launch Instances.
3. Under the Name and tags section :
· Name : MyWordPress_Instance
4. Under the Application and OS Images (Amazon Machine Image) section :
· Select Quick Start tab and Amazon Linux under it
· Amazon Machine Image (AMI): select Amazon Linux 2 Kernel AMI or any AMI as per your choice.
5. Under the Instance Type section :
· Instance Type : Select t2.micro
6. Under the Key Pair (login) section :
· Click on Create new key pair hyperlink
· Key pair name: Mykey
· Key pair type: RSA
· Private key file format: .ppk
· Click on Create key pair and select the created key pair
We may need the key to access the instance if in case, need any configuration to be made later.
7. Under the Network Settings section :
· Click on Edit button
· Auto-assign public IP: select Enable
· Firewall (security groups) : Select Select existing security group
· Common security groups : Select MyWordPress_SG
8. Under the Advanced details section :
Under the User data: copy and paste the following script which has the details for installing wordpress, apache server and mysql.
#!/bin/bash
# Enter root access
sudo -s
# Update the os
yum update -y
# Install Apache server
sudo yum install -y httpd
# Install wordpress
sudo amazon-linux-extras install -y php7.2
# Install Wget
yum install wget -y
# Download MySQL Community
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
# Install MySQL
rpm -ivh mysql-community-release-el7–5.noarch.rpm
# Install MySQL Server
yum install mysql-server
# Install PHP-MySQL
yum install php-mysqlnd -y
# Enter html directory
cd /var/www/html/
# Create html file
echo "TrialFile" > Trial.html
# Download wordpress
wget https://wordpress.org/latest.tar.gz
# Extract the file
tar -xzf latest.tar.gz
# Coping the wordrpress to html folder
cp -r wordpress/* /var/www/html/
# Remove the folder
rm -rf wordpress
# Remove the file
rm -rf latest.tar.gz
# Give Permisson to the folder
chmod -R 755 wp-content
# Own the file and folders
chown apache:apache /var/www/html
# Check httpd config
chkconfig httpd on
# Start the httpd service
service httpd start
9. Leave others as default and click on the Launch instance button.
10. Your instance is now launching, Navigate to Instances page from the left menu and wait until the status of the EC2 Instance changes to Running.
1. Once EC2 Instance status changes to Running State, copy the Public IPv4 Address of your EC2 instance from the details section.
2. Open a new web browser tab, paste the IP address and press Enter.
3. If the user data script entered while launching an EC2 instance is correct, the browser will show the WordPress welcome page.
4. Before you click on Let’s go!, keep the Database name, Database username, Database password and Database host (endpoint) details in handy, which was provided during RDS DB instance creation.
5. Click on Let’s go!
6. Enter the Database details you have noted while creating the DB instance. Leave the table prefix as default and click on Submit.
7. Click on Run the Installation in the next page.
8. Provide the required details:
§ Site Title: Enter My First Blog
§ Username: Enter wp_admin
§ Password: Enter Strong password
§ Your Email: Enter your email address
§ Click on Install WordPress.
Click install.
1. Once you have clicked on the Install WordPress, a login page appears. Click on Log In and enter the Username and Password, configured in the previous step.
2. After the login, you will be redirected to the WordPress dashboard, where you can edit your wordpress website. If you remove wp-admin from the URL, the public facing site will be loaded.
???? Congratulations on completing this exhilarating journey into the realm of web hosting with Amazon EC2 and RDS MySQL! You’ve not just set up a website; you’ve crafted a high-performance, scalable digital masterpiece.
As we wrap up, remember that your website is now fortified by the dynamic duo of Amazon EC2 and RDS MySQL, seamlessly orchestrated by the reliable Apache Server. The WordPress CMS adds the final touch, turning your online presence into a canvas where creativity knows no bounds.
Stay curious, keep exploring, and let your website become the canvas for your digital dreams. Thank you for reading my article. Here’s to your web hosting success! ????
Happy Cloud Computing ☁️????????