🔰Deploy WordPress Application with Amazon RDS🔰
Task-18 Description📄
🔅 Create an AWS EC2 instance
🔅 Configure the instance with Apache Webserver.
🔅 Download PHP application name “WordPress”.
🔅 As WordPress stores data at the backend in MySQL Database server. Therefore, you need to setup a MySQL server using AWS RDS service using Free Tier.
🔅 Provide the endpoint/connection string to the WordPress application to make it work
Step 1: Configure RDS for providing MySQL database service to our WordPress App.
👉Go to AWS RDS service. Click the orange Create database button to get started.
👉Creating the Database. WordPress uses MySQL, so select that engine.
👉We don’t want that any charges implemented on this experiment. Next, you will specify the authentication settings for your MySQL deployment. This includes the database name and the master username and password.
In the Settings section, enter WordPress as your DB instance identifier. Then specify the master username and password for your database. Choose a strong, secure password to help protect your database. Store the username and password for safekeeping as you will need it in a later module.
After setting your username and password, you can select key details about your MySQL deployment. This includes the instance class and storage details.
The default settings will work for this lab. You will use a small instance class that is suitable for testing or small-scale applications, and it fits within the AWS Free Tier. If you don’t want to use the AWS Free Tier, you could set a larger instance class or alter the storage configuration options.
👉We can create our own customized VPC as well. Also the public access is allowed in order for testing, but in real time we need to customize it.
👉After some minutes, it will be in Available state.
👉In this module, you created a fully-managed MySQL database using Amazon RDS. In the next step, you will create an Amazon EC2 instance for running your WordPress site.
Step 2: Creating an EC2 instance
👉To create EC2 instance, go to Amazon EC2 in the AWS console. Click the orange button that says Launch instance to open the instance creation wizard.
In the first page, you will choose an Amazon Machine Image (“AMI”). The AMI you choose will determine the base software that is installed on your new EC2 instance. This includes the operating system (Amazon Linux, Red Hat Enterprise Linux, Ubuntu, Microsoft Server, etc.), as well as the applications that are installed on the machine.
👉Choosing an instance type.
On the second screen of the EC2 wizard, you will select an EC2 instance type. An instance type is a particular configuration of CPU, memory (RAM), storage, and network capacity.
👉Configure Instance
👉Configuring a security group
Security groups are networking rules that describe the kind of network traffic that is allowed to your EC2 instance. You want to allow two kinds of traffic to your instance:
SSH traffic from your current IP address so you can use the SSH protocol to log into your EC2 instance and configure WordPress;
HTTP traffic from all IP addresses so that users can view your WordPress site.
👉It is now time to launch your EC2 instance. Click the blue Launch button to create your EC2 instance.
👉Successfully launched EC2 instance.
In the next step, we will configure your RDS database to work with your EC2 instance.
Step 3: Creating a database user
We have an active SSH session to our EC2 instance in the terminal. Now, we will connect to your MySQL database.
First, run the following command in the terminal to install a MySQL client to interact with the database.
sudo yum install -y mysql
Next, find the hostname for your RDS database in the AWS console. In the details of your RDS database, the hostname will be shown as the Endpoint in the Connectivity & security section.
In your terminal, enter the following command to set an environment variable for your MySQL host. Be sure to replace “<your-endpoint>” with the hostname of your RDS instance.
export MYSQL_HOST=<your-endpoint>
👉check the connection, using command: “mysql -h endpoint_url -u username -p”
step 4: Configuring WordPress on EC2
To configure WordPress, we need to first install
- httpd
- php (version 7.4 or more)
- php-mysqlnd
Lets install them one by one,
👉Commands to be used are :
httpd: “yum install httpd”
php:
“yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm ”
“yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm”
“yum install php:remi-7.4”
php-mysqlnd : “dnf install php-mysqlnd”
To start the Apache web server, run the following command in your terminal:
systemctl start httpd
👉To setup WordPress, we need to download the zip file first.
command: “wget https://wordpress.org/latest.tar.gz”
👉Now, we will unzip this file.
command: “tar -xzvf latest.tar.gz”
👉Transfer these files to the document root.
command: “rsync -avP ~/wordpress/ /var/www/html/”
👉Create a folder for the data that will be uploaded by the users.
👉At last update the Apache permissions to the WordPress files
👉Now Restart the httpd service, using command: “systemctl restart httpd”
Accessing the WordPress, through the WordPress
👉To access the WordPress, use the public IP of the EC2 instance.
👉Configure WordPress now
👉you can see that my first blog.
Finally we have successfully complete the task.