Deploy WordPress on EC2 by WordPress AMI
Tags: aws, ec2, wordpress, awscommunitybuilders
Published: 2023-02-27 22:36:51

- Wordpress
WordPress is a highly popular content management system (CMS). It is most commonly used for blogs but can also be used for running e-commerce sites, message boards, company websites, Portfolio Websites and many other popular use cases. In this guide, you will learn how to set up a WordPress site to run a blog.



- AWS Services services that use in this project
An [Amazon EC2](https://aws.amazon.com/ec2/) instance to install and host the WordPress application.

## Implementation



### Creating an EC2 INSTANCE and Choosing an Amazon Machine Image

a. Open the [AWS Management Console](https://console.aws.amazon.com/console/home). When the screen loads, enter **EC2** in the search bar, then select **EC2** to open the service console.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scwb9efl1udg254pkbnl.png)

b. Choose the **Launch instance** button to open the instance creation wizard.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shoffnezqld1resk3rwg.png)

c. On the first page, enter _wordpress app_ as your instance name.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9t1609p9dqeo8cvgft6.png)

d. Next, 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.), and the applications that are installed on the machine.

Many AMIs are general-purpose AMIs for running many different applications, but some are purpose-built for specific use cases, such as the Deep Learning AMI or various AWS Marketplace AMIs.

WordPress image is certified by Bitnami as secure, up-to-date, and packaged using industry best practices, and approved by Automattic, the experts behind WordPress, so choose [WordPress Certified by Bitnami and Automattic](https://aws.amazon.com/marketplace/pp/prodview-bzstv3wbn5wkq) after make search on AWS Marketplace AMIs in the AMI selection view.

so write **Wordpress** on search bar then click **Enter**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4etvybh7ff0njhfn9iji.png)

e. You will find the first image, choose it and press on **Select**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7q7j30isay2ddd0ennnv.png)

f. Read overview and all details about AMI then click **Continue**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6g7vpnlkdvrphk4x4jg.png)

g. You will return to the AMI Section and you will find that the image has been selected.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a09ub302iz2s8gn4htk9.png)

### Choosing an instance type

Scroll down to select an EC2 instance type. An instance type is a particular configuration of CPU, memory (RAM), storage, and network capacity.

AWS has a huge selection of [instance types](https://aws.amazon.com/ec2/instance-types/) that cover many different workloads. Some are geared toward memory-intensive workloads, such as databases and caches, while others are aimed at compute-heavy workloads, such as image processing or video encoding.

Amazon EC2 allows you to run 750 hours per month of a t2.micro instance under the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). 

But in this image .. AMI vendor recommends using **t3a.small** instance

a. Select the **t3a.small** instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6uv2z21bn4nnrv3f4pr.png)

### Configuring an SSH key

You will see a details page on how to configure a key pair for your instance. You will use the key pair to [SSH](https://en.wikipedia.org/wiki/Secure_Shell) into your instance, which will give you the ability to run commands on your server.

a. Open the **key pair (login)** section and choose **Create new key pair** for your instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pt60j4hp5tvrrtydd1fc.png)

b. Give your key pair a name. Then choose **.ppk** in Private Key file format to can use with PuTTYThen. Then choose the **Create key pair** button, which will download the .ppk file to your machine. You will use this file later.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxaypclsz2y6y76nddly.png)

c. You will return to Key pair (login) Section and you will find that Key has been selected.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn3cv2enaznxgjhklhc0.png)

### Configuring a security group and launching your instance

You need to configure a security group before launching your instance. Security groups are networking rules that describe the kind of network traffic that is allowed to your EC2 instance. You want to allow traffic to your instance:
- SSH traffic from all IP addresses so you can use the SSH protocol to log in to your EC2 instance and configure WordPress.
- HTTPS traffic from all IP addresses so that users can view your WordPress site Secured.
- HTTP traffic from all IP addresses so that users can view your WordPress site.
 
a. To configure this, select **Allow SSH traffic from Anywhere** and select **Allow HTTPS & HTTP traffic from the internet** (These are the default choices when choosing an Wordpress AMI).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsxmaqcwhv795knvdlbg.png)

### Configuring storage on instance

a. Here we can increase the storage space for the Root volume and also can be added more volume storage.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rh7e9n52p4elxgdcbew4.png)

### Launch

It is now time to launch your EC2 instance.
a. Choose the **Launch instance** button to create your EC2 instance.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxx4x27z822scha86xnh.png)

b. Wait for instance to launch.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r69behvsfnpbvwcrfyon.png)

c. You have successfully launched your EC2 instance. Click on **Open address** to view website. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppg2kze77mmd9e6udf9r.png)

### Deploying Wordpress

a. You should see the WordPress welcome page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xcvt0a4r1akcr1v72yx.png)

b. Add _/wp-admin_ after the end of the link to reach the admin page to manage everything on the site.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukrn433x9dtkd80ihj9k.png)

c. You should see the WordPress login page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inndfcx8r8c2xhm8j2ot.png)

### SSH into your EC2 instance to know login information

You will use SSH to connect to your EC2 instance and run some commands.

a. Go to the [EC2 instances page](https://console.aws.amazon.com/ec2/v2/home#Instances) in the console. You should see the EC2 instance you created for the WordPress installation. Select it and you will see the Public IPv4 address and the Public IPv4 DNS in the instance description.
Click on **Copy** icon to copy public ip

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyr1etjtn5bx2qyfuhkd.png)

b. Open [**PuTTY**](https://www.putty.org/) appliction and paste public ip in _Host Name (or IP address)_.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/odimwzu3phhjo48240ib.png)

c. Click on **+** the one next to SSH in Category list.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlx7fd3j38t42pqyb019.png)

d. Then click on Auth.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sr2lndcc7xjnoop5jhbs.png)

e. In Private Key file for authentication, Click on **Browse**

Previously, you downloaded the .ppk file for the key pair of your instance. Locate that file now. It will likely be in a Downloads folder on your desktop.

open this .ppk file

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c8fyk5k83wb7ce384fq2.png)

f. Click on **Open**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wyziggolvnk4zx8vk8d.png)

g. You should see the following in your terminal to indicate that you connected successfully.

then you will log in with **bitnami** (bitnami is deafult).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bkoidylgipvq3anqfyu.png)

### Wordpress Credentials

a. Run the following command to see your application credentials.
```
sudo cat /home/bitnami/bitnami_credentials
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ihm4q6ejz9ox2jl0lx7p.png)

b. You will find WordPress Credentials, make copy for username and password.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugnh0obq04az8kof792i.png)

c. Back to WordPress Admin login then make paste for username and password then click on **Login**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1i7ivzega90dhoq14zh.png)

d. You should see the WordPress Admin page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecbah4z61vaa3tng4p3h.png)