Step by step to deploy and host a high-available WordPress application using AWS EC2 instance,RDS,ASG and VPC (Part-1)
Tags: aws, beginners, programming, wordpress
Published: 2023-08-05 14:14:06

## How this post will help?
   Learn and build a WordPress application using AWS EC2 instance with Amazon RDS DB instance that is external to AWS Elastic Beanstalk, then how to configure a high-availability environment  running a WordPress website to connect to it. Then website uses Amazon EFS  as the shared storage for upload files.

## Amazon RDS High Availability:
Running a DB instance external to Elastic Beanstalk decouples the database from the lifecycle of your environment. This lets you connect to the same database from multiple environments, swap out one database for another, or perform a **blue/green** deployment without affecting your database.

## Prerequisites:
- Basic Elastic Beanstalk operations and Beanstalk console.
- Command line terminal(Linux or MacOS) or Cloudshell.
- Basics of aws concept.

## First, we launch a DB instance in Amazon RDS:

Its completely independent from Elastic Beanstalk Environments and will not be terminated or monitored by Elastic Beanstalk 

Follow step by step to launch a database with the **MySQL engine** and enable **Multi-AZ deployment**

1. Open the AWS RDS console and click `Databases` in side navigation pane.
1. Choose `Create database` and choose `Standard Create` (Don't choose `Easy Create`).
1. In Availability and durability choose `Multi-AZ DB instance ` (Review the default settings and adjust these settings according to your specific requirements).
1. Master **username** and Master **password** – The database username and password. Make a note of these settings because you will use them later.
1. Under Additional configuration, for Initial database name, type `ebdb`
1. Verify the default settings for the remaining options, and then choose `Create database`.

![AWS RDS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30sq6eov61ipzdqrk4bn.png)
We created MySQL database in AWS RDS instance.

**Note :** Check whether the inbound rules on the security group that's attached to your RDS instance. If not go to inbound and attach the security group.

![SG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxbob8omaqwycywtp4ht.png)

## Download WordPress:

To prepare to deploy WordPress using AWS Elastic Beanstalk, you must copy the WordPress files to your computer and provide the correct configuration information.

**To create a WordPress project:**

- Download WordPress from [wordpress.org](https://wordpress.org/download/)

```
~$ curl https://wordpress.org/wordpress-4.9.5.tar.gz -o wordpress.tar.gz
```

![WordPress Install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuestgzg5gniwjqbugqy.png)

- Download the configuration files from the sample repository


```
~$ wget https://github.com/aws-samples/eb-php-wordpress/releases/download/v1.1/eb-php-wordpress-v1.zip
```

![CLI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uhw2evwdc31pkh50b500.png)

- Extract WordPress and change the name of the folder.

```
 ~$ tar -xvf wordpress.tar.gz
 ~$ mv wordpress wordpress-beanstalk
 ~$ cd wordpress-beanstalk
```

![MV file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yulvccmmrhxbmzrhe9zs.png)

- Extract the configuration files over the WordPress installation.

```
~/wordpress-beanstalk$ unzip ../eb-php-wordpress-v1.zip
```

## Launch an Elastic Beanstalk environment:

Use the Elastic Beanstalk console to create an Elastic Beanstalk environment.

In the following steps, you'll use the Elastic Beanstalk console to:
- Create an Elastic Beanstalk application using the managed PHP platform.
- Accept the default settings and sample code.

**To launch an environment:**

- Open ElasticBeanstalk console using [Pre-Link](https://console.aws.amazon.com/elasticbeanstalk/home#/newApplication?applicationName=tutorials&environmentType=LoadBalanced)
 and click `Create application`

- For `Platform`, select the platform and platform branch that match the language used by your application.
- For `Application code`, choose `Sample application`.
- Choose `Review` and `launch`.
- Review the available options. Choose the available option you want to use, and when you're ready, choose `Create app`.

![Beanstalk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8jpl2fsz7kcvu1v1384.png)

We created beanstalk environment successfully.

In Part-2, We will see how to confirm beanstalk environmental ,external AWS RDS and final Wordpress deployment. 

**Follow and Share for more update**