Categories
Building This Site

Hosting WordPress with AWS EC2 (with Domain from Route 53)

This 3-part guide will describe how I got started with WordPress and AWS to host this blog. There is nothing new here that you cannot find in the official AWS Launch a WordPress Website tutorial and I recommend reading it to get more details about each step. My goal is to simplify the article and complement it with some super cool GIFs to illustrate the process. I will also describe how to get your domain name registered with AWS Route 53, connect via SSH, and remove the Bitnami banner that comes by default with the WordPress AMI. Let’s get started!


PART 1: WORDPRESS + AWS EC2

1.1 Create an AWS Account

AWS has a Free Tier account which lets you explore most of their services for a year for free. It is a great way to try their more than 60 products so I highly recommend creating an account with them.

1.2 Create an EC2 Instance

1.3 Select WordPress AMI from the Marketplace

There is a WordPress AMI (Amazon Machine Image) certified by Bitnami and Automattic (the company behind WP).

1.4 Configure Instance

Select the Instance type (t2.micro is eligible for the Free Tier), leave the default instance details and the default storage.

1.5 Name your Instance

This step is optional but it will help you easily identify it in the next steps.

1.6 Launch and Download Key Pair

Make sure you save those keys in a safe place. You will use them to connect via SSH to your instance in PART 3.

1.7 Obtain your Public IP

Go to the EC2 Dashboard (see 1.2) and click on your new instance. I named mine MyBlog.

1.8 Congrats! You Have a New Blog!

Copy and paste your public IP in the browser and you should see your new blog up and running!
At the time of this writing, the default theme was TwentyNineteen, yours could be a newer version.

1.9 Getting your WP Admin Credentials

Go to the EC2 Dashboard, select your instance and view the System Log.

Scroll to the botom and you should find your credentials surrounded by hash lines.
I have blurred my password for obvious reasons.

That’s it! Go to [YOUR_PUBLIC_IP]/admin and enter your WP admin credentials.

PART 2: DOMAIN NAME WITH ROUTE 53

2.1 Obtain a Static URL

Go to Elastic IPs and allocate a new address.

Now, select your new address and associate it to your EC2 Instance.

Give it a name to identify it easily. I recommend that you give it the same name as your instance.

2.2 Register a Domain Name

Go to the Console home and search for Route 53.

Click on Registered Domains and complete the checkout process.

2.3 Configure DNS

Disclaimer: For the next steps, I didn’t record GIFs because I already had my domain. Sorry 🙁

Open the Hosted Zones part of Route 53 console and click on the domain name you just purchased.

Click the Create Record Set button. On the window on the right, enter www in the name text box. Finally, enter the Elastic Public IP you created in Step 2.1 in the value box and click Create.

Verify that you have a new entry in the main table with the value you entered. Your website should be available with your new domain name!
Note: In my case, I had to wait around 2 hours to access my new domain so be patient if you don’t see it immediately.

PART 3: CONNECT VIA SSH

3.1 Setup SSH

I will show you how to connect to your instance using Mac. For Windows, check this tutorial.

Before we start, you need to have SSH installed. Most Mac and Linux machines already have it by default so go ahead and open a terminal window and type the command ssh. If your computer doesn’t recognize the command, you can download a free implementation from the OpenSSH project.

  1. Open a new Terminal window.
  2. Move your downloaded credentials to the ./ssh directory.
  3. Change to the ./ssh directory.
  4. Use the chmod command to make sure your private key file is not publicly viewable.

Now you can connect via SSH to the instance by running the command:
ssh -i [YOUR_CREDENTIALS].pem bitnami@[YOUR_PUBLIC_IP]
You should see the Bitnami welcome screen. To change directory to the WordPress files type:
cd apps/wordpress/htdocs/

3.2 Remove the Bitnami Banner

We are almost! We only need to remove the Bitnami banner on the bottom right of your new site.

While connected to your EC2 Instance via SSH, run the following command:
sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

Now just restart Apache with this command:
sudo /opt/bitnami/ctlscript.sh restart

That’s it! Give yourself a round of applause because you have just launched a WordPress website hosted on AWS EC2 with your own domain name and SSH access. In a follow-up post, I will write about adding SSL to your new WP site, downloading a copy of your MySQL database, setting up a GitHub repository and deployment.

This is my first ever written tutorial so I hope you enjoyed it as much as I enjoyed writing it. If you have comments or feedback feel free to email me at maichomper[at]gmail.com. Thanks for reading!

– Micho