How to Host a WordPress Site on AWS using Amazon Lightsail

·

4 min read

In this blog post, we will learn how to host a WordPress Site on AWS using Amazon Lightsail and we will use a custom domain for our website.

Pre-requisites:

  • AWS Account

  • Custom domain in AWS

First, log in to your AWS account and search for Lightsail.

Click on Create Instance. Select your Instance location, which ever is nearest to your location, mine is in Singapore. Click on Linux/Unix and select WordPress.

For the Instance Plan, select the cheapest one for now which costs $3.5 per month. It says here that your first 3 months is free! But in case your website performance will become slow, you can review all the different pricing tiers below and upgrade your instance plan.

Enter your desired instance name or you can leave by default and click Create Instance.

Wait for few minutes until your instance status changed from "Pending" to "Running". Here you can see the public IP Address of our instance: 18.181.197.13

If you search your public IP Address in another tab, it will redirect you to the default WordPress website that Amazon Lightsail provided.

Put /wp-admin after the public IP Address and it will redirect you to your WordPress Site login page.

Navigate back to Amazon Lighsail and click >- from your instance.

From your terminal, you can type some Linux commands to see where you are like pwd or ls. For us to get the default password of our WordPress website, type in cat $HOME/bitnami_application_password and hit enter. It will show your password: swM3jyM1na92. Copy the password on your terminal and close it.

Navigate back to the WordPress login page. Type user as your Username and enter your password, then click the Log In button.

Once you're login, the first thing that we need to do is change the password. Click on Users. On this page, you can click on "Add New" to add a new user. To change the password of our account, click the "Edit" option.

Scroll down and under Account Management. Click on Set New Password and enter a strong password, then click the Update Profile button to save your new password.

Once your password is changed, you can click on Appearance to customize your website. But for now, we'll skip that part because we will setup our own custom domain name first.

Navigate back to your instance and click your instance name "WordPress-1" to see our Public IP Address.

We will create a static IP Address because in any case that this instance will fail, our public IP address can change. And we don’t want to wire up our IP address to our domain name every time the IP address will change that’s why we need a stable, not changing IP address. To assign a Static IP Address to our instance, click on the Networking tab. Under the IPv4 networking, click the attach static IP under your Public IP Address, select Create Static IP and attached.

Here, our IP address changed to a Static IP Address 52.193.12.199. You can click "Detach X" in case you want to detach this Static IP from your instance. Copy your Static IP Address.

We will now set up our domain name. Navigate to the AWS console https://console.aws.amazon.com/console/home and search for Route53.

On this Page, you will see that I have 1 registered domain and 1 hosted zone that AWS provided when I registered my custom domain. Click on "Hosted Zone"

and click your Hosted zone name.

We're going to wire up our Static IP address to our custom domain. For us to do that, click on "Create record".

Select Simple Routing policy and click Next.

Click on "Define simple record".

Leave the subdomain as blank. For the Record type, select A - Routes traffic to an IPv4 address and some AWS resources, then paste your Static IP Address. Leave the TTL on default and click on Define simple record.

Click Create records.

Now, we will need to create another record so when we type boibanez.com, it will also redirect us to WordPress website.

Click Create Record again, select Simple Routing policy and click Next. Click on "Define simple record". This time, we will put www for the subdomain. For the Record type, select A - Routes traffic to an IPv4 address and some AWS resources, then paste your Static IP Address. Leave the TTL on default and click on Define simple record and click on Create Record.

We now have 2 record names of that points to our Static IP Address.

If I search my domain name boibanez.com, it will redirect me to my wordpress website.

Same if I search using boibanez.com.

I can now log in to my website using boibanez.com/wp-admin or boibanez.com/wp-admin to customize my website.

Hope you liked this post, feel free to reach out to me on Twitter or LinkedIn.