ARTH - Task 18 👨🏻💻
Task Description📄
🔅 Create an AWS EC2 instance
🔅 Configure the instance with Apache Webserver.
🔅 Download PHP application name "WordPress".
🔅 WordPress stores data at the backend in the MySQL Database Server. Therefore, you need to set up a MySQL server using AWS RDS service using Free Tier.
🔅 Provide the endpoint/connection string to the WordPress application to make it work.
Requirements
- AWS CLIV2
- 2. AWS EC2
- AWS RDS
- WORDPRESS
- 5. HTTPD MYSQL PHP
AWSCLIV2 -
The AWS Command Line Interface (AWS CLI) is an open-source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI enables you to start running commands that implement functionality equivalent to that provided by the browser-based AWS Management Console from the command prompt in your terminal program:
- Linux shells – Use common shell programs such as bash, zsh, and tcsh to run commands in Linux or macOS.
- Windows command line – On Windows, run commands at the Windows command prompt or in PowerShell.
- Remotely – Run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances through a remote terminal program such as PuTTY or SSH, or with AWS Systems Manager.
AWS EC2 -
Amazon Elastic Compute Cloud (EC2) is a part of Amazon.com's cloud-computing platform, Amazon Web Services (AWS), which allows users to rent virtual computers on which to run their own computer applications. EC2 encourages the scalable deployment of applications by providing a web service through which a user can boot an Amazon Machine Image (AMI) to configure a virtual machine, which Amazon calls an "instance", containing any software desired. A user can create, launch, and terminate server-instances as needed, paying by the second for active servers – hence the term "elastic". EC2 provides users with control over the geographical location of instances that allows for latency optimization and high levels of redundancy.In November 2010, Amazon switched its own retail website platform to EC2 and AWS.
AWS RDS -
Amazon Relational Database Service (or Amazon RDS) is a distributed relational database service by Amazon Web Services (AWS). It is a web service running "in the cloud" designed to simplify the setup, operation, and scaling of a relational database for use in applications. Administration processes like patching the database software, backing up databases, and enabling point-in-time recovery are managed automatically. Scaling storage and compute resources can be performed by a single API call to the AWS control plane on-demand. AWS does not offer an SSH connection to the underlying virtual machine as part of the managed service.
WordPress -
WordPress (WP, WordPress.org) is a free and open-source content management system (CMS) 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. WordPress was originally created as a blog-publishing system but has evolved to support other web content types including more traditional mailing lists and forums, media galleries, membership sites, learning management systems (LMS) and online stores. WordPress is used by more than 60 million websites,including 39% of the top 10 million websites as of January 2021, WordPress is one of the most popular content management system solutions in use WordPress has also been used for other application domains,o such as pervasive display systems (PDS).
HTTP MYSQL PHP -
PHP is a general-purpose scripting language especially suited to web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994 The PHP reference implementation is now produced by The PHP Group.[7] PHP originally stood for Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.
HTTP Daemon is a software program that runs in the background of a web server and waits for the incoming server requests. The daemon answers the request automatically and serves the hypertext and multimedia documents over the Internet using HTTP.
MySQL is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language. A relational database organizes data into one or more data tables in which data types may be related to each other; these relations help structure the data.
Let's start the task
In this task I will show both GUI and CLI parts for both creating an ec2 instance or creation of RDS for CLI cmd we have to install the AWSCLIV2 software in our window that is provided by the AWS official to do tasks via CLI without using any API. and for passing credentials, we have to create an IAM role. and while writing I use PowerShell of the window so I can get easy copy-paste. and for GUI in case of ec2 we can log in to ec2 console and perform our task of launching ec2 instance step by step. and for RDS we have to log in to the rds console and provide the info to the console for creating rds. and after completing launching of instance and rds we can take endpoint from rds and in the instance we have to make a setup for installation of WordPress-site so that we can easily download WordPress and start its service without any problem for this we have to install many rpm's like MariaDB, PHP-fpm MySQL and many more like httpd. and after all this, we can start the service and access the host URL with WordPress via browser, and then we can configure our WordPress config, and here we have to provide our RDS endpoint that we can get from AWS rds console. after doing all these steps we get our task complete. so let's see step by step with describing each step.
GUI RDS SETUP -
- After login, we have to go to the RDS console. and click on the CREATE DATABASE button.
2. Now we have multiple fields that we have to fill for the setup of our RDS database server like we have to select which Engine to use or which method to opt for creating the RDS.
Selection of Database engine Version we opt to perform our task and Selection of templates like Production and Free-Tier.
Config setting of RDS like name of our server and user name and password of our database that we can create inside our server.
Selection of Storage and Selection of Database instance size based on our use-case as we are free tier so only one we have to select
allowing Autoscalling of DB when needed
Selection of VPC .subnet Public access and launch wizard
Providing port on which our server works by default 3306 and enabling of Password-based authentication
Giving BAckup policy and databases name
For the final creation of the database, we have to select all the above-mentioned portions for our RDS server.
after doing all these steps we get our rds server ready via GUI and we now for EC2 GUI
as this is the normal scenario it only makes our article long so I skip it.
SETUP OF RDS AND EC2 VIA CLI
RDS
aws rds create-db-instance # cmd used for creating rds database --db-name MYDB1 # by the help of this we asign the name of db # # that create inside db-server --db-instance-identifier mydb-test #by this we give name of db-instance --allocated-storage 10 # By this we assign storage for our db --db-instance-class db.t2.micro # By this we assign the class of db-instance --engine mysql # By this we select the Engine type of server --engine-version 5.7.31 # By this we select version of db-engine --master-username gaurav # By this we give our db master user --master-user-password 123456789 # By this we assign password on db --availability-zone ap-south-1a # By this we select which zone used to launch --port 3306 # By this port selectio on which service work --storage-type gp2 # By this we give our storage type of instance --vpc-security-group-ids sg-03fa5 # By this we select vpc-sg --no-publicly-accessible # By this we give Permission --max-allocated-storage 21 # By this we give top size of colume
After running this we can launch our RDS database server very easily with all this property that we write in the command section.
As Our RDS is configured Successfully So we can copy our Endpoints easily and this endpoint we use in last of our WordPress configuration without this the Integration of MySQL with WordPress is not possible or we can WordPress launch only when this work fine without any issue. We can get Endpoint via this cmd
aws rds describe-db-cluster-endpoints
By this, we get our endpoint that we can use to perform our task
Now Start EC2
aws ec2 run-instances # cmd for creating ec2 --image-id ami-04b1ddd35f******* # To select ami --instance-type t2.micro # To select Instance-type --subnet-id subnet-******** # To select subnet --key-name arth # To select Key-Pair --security-group-ids sg-0****** # To select SG
By this cmd we get our EC2 instance running that's is our requirement by this cmd now we have to configure this as WordPress application host that use RDS Mysql database as a Storage database for there self so for this we have to do MAny steps so lets d that also
- the first login to the system with root user
- upgrade yum
- Install PHP-fpm Php-mysqlnd MariaDB-server tar httpd
- amazon-Linux-extras install PHP7.3
After all this, we have to start the service of httpd
Download WordPress and Configure it
curl https://wordpress,org/latest.tar.gz --output word.tar.gz tar xf word.tar.gz cp -r wordpress/* /var/www/htmk/ chown -R apache:apache /var/www/html/wordpress systemctl enable htttpd --now
So now we can access WordPress Config page on our Browser
HTTP://instance-ip/wordpress/
Here we use endpoints master user password
it means all ok WordPress can connect to mysql
Provide info for WordPress Config as shown on our site
logging in into wordpress
Our WordPress Application Launched Succesfullu without any issue it means our MySQL connectivity is also good so our rds server is working file lets see our rds server report after installation of WordPress
This ss show in our rds MySQL server many tables and entries are in the Mysql server with WordPress name so it means Integration of AWS EC2 WITH AWS RDS SUCCESSFUL.
THANKS fOR rEADING HAVE A NICE DAY