ARTH Task18
In this article we are going to explain how to we can configure WordPress on ec2 instances and connect this with Amazon RDS (Relational Database Service) MySQL.
Task 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.
Prerequisite
- You should have your AWS account.
- basic knowledge of Linux OS.
- basic knowledge of MySQL.
What is RDS?
Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups.
what is WordPress?
WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database. Features include a plugin architecture and a template system, referred to within WordPress as Themes.
Lets begin......
Step 1 :- First create the MySQL RDS.
- In Database click on RDS.
- Click on Create database.
- Select MySQL
- select latest version of MySQL and free tier so that they will not charge any cost.
- Name your database and set user name and password for your database
- Leave rest of setting default. and In the Public access select yes otherwise you won't be able to connect to WordPress.
- choose the security group if you have already created any , otherwise you can create new one.
- now click on create database.
- It will take few min to launch , so wait for some time.
Step 2:- Launch ec2 instances and configure WordPress.
- Below is step to create ec2 instances.
- click on connect to connect to your ec2 instances.
- run "sudo su - root" to become root user so that you can run all the command with root privilege.
- To setup the WordPress we need to install some software.
- "yum install httpd -y" and "yum install mysql -y" to install httpd and mysql.
- Run "amazon-linux-extras enable php7.4" command to get command to install php.
- Run those two command given in the above image to install php.
- Now go to the official site of WordPress https://wordpress.org/download/ and copy the download link.
- go to the "cd /var/www/html/" folder.
- Run the "wget https://wordpress.org/latest.tar.gz" command to download the wordpress software.
- and "tar -xf latest.tar.gz" to unzip the Wordpress software.
- Enable the httpd service. and enter your public IP of ec2 instance on browser followed by your wordpress folder "publicIP/worpress".
Step 3 :- Check your RDS MySQL database connectivity.
- copy your database endpoint
- Run the below command to connect your database. enter your correct endpoint , user and password in this command.
- If you have some knowledge of mysql then you can run mysql command to check database and tables.
- go to the wordpress folder and copy wp-config-sample.php to wp-config.php
- now open this wp-config.php file and enter the database name, user , password and endpoint of RDS mysql database.
- Restart httpd and mysql service.
- now again go to the browser and refresh the page and enter the details and click on install wordpress.
- login to wordpress site.
- click on "view your site".
- now click on Edit to edit your wordpress site accordingly.
- Now I am going to comment on this site so that i will have some data in my database.
- Now again login to your Mysql database to see the data is storing or not.
- go to your wordpress database which is sqldb in my case. and see your tables.
- If you will print the wp_posts you will to able to see content your post.
- Now If you will see the data of wp_comments then you will see the same comment that i have commented on my wordpress site.
- Now we can verify that RDS MySQL and WordPress are working good together.