Hosting WordPress on AWS

What better way to practice my new-found Cloud skills than to host something on my own? To kick start my Learning in Public journey, I needed an outlet to share. I began with the end in mind by setting out with these goals:

  • Host my own WordPress site on AWS
  • Stay within Free Tier (except Route 53 domain registration)

Let us first take a look at the AWS WordPress reference architecture from :

I almost fell off my chair! AWS WordPress reference architecture meant for a full-scale enterprise set up will end up being prohibitively expensive for a personal WordPress site! The reference architecture will definitely be outside of the Free Tier usage, and hence did not meet my requirement.

So I came up with this:

To explain some of the components I am using:

  • Route 53: Public hosted zone and domain name registration
  • EC2 Instance (t2 micro): WordPress + NGINX on Amazon Linux 2 AMI
  • RDS Instance: MySQL

Configuring VPC, Route Tables and Security Groups

In the Singapore region, I created a new VPC with 2 subnets within it, a public and a private subnet. I created a default route to the Internet Gateway for the public subnet, and both subnets can route to each other by default locally within the VPC.

For security groups, I’ve configured the EC2 instance to only allow inbound SSH and HTTP traffic, while the RDS instance only allow MySQL/Aurora (port 3306) inbound.

Installing NGINX and PHP

After spinning up an EC2 instance, we need to access it via SSH to install NGINX and PHP. My steps are as follow:

To install NGINX and start the service, run the following commands:

amazon-linux-extras install nginx1.12
service nginx start
service nginx status
chkconfig nginx on

To install PHP, run the following commands:

amazon-linux-extras install php7.3
service php php-fpm start
service  php php-fpm status
chkconfig  php php-fpm on

To configure PHP FPM for wordpress, run the command:

vim /etc/php-fpm-.d/www.conf 

Make the following edits in the file.

user = nginx (original user = apache)
group = nginx (original group = apache)
listen =

To save and exit vim, press Esc, Type :w, and press Enter.

Downloading WordPress

I ran the following commands:

mkdir /var/www 
cd /var/www 
tar xvf latest.tar.gz 
sudo chown nginx:nginx -R /var/www/wordpress 
sudo find /var/www/wordpress -type d -exec chmod 755 {} \; 
sudo find /var/www/wordpress -type f -exec chmod 644 {} \; 

Configuring NGINX

I followed the official recommendation from to configure NGINX for wordpress. Make sure to reload nginx and restart the nginx and php-fpm services after you are done.

Final Steps

Create your RDS instance before visiting your EC2 public IP address and installing WordPress. During installation specify your database configuration information and your WordPress should install just fine. Remember to make sure your EC2 has the appropriate IAM roles to RDS.

Feel free to contact me if you require help with your own set up or have suggestions on how I can do better.

What’s next?

As I near the end of Free Tier, I need to look for alternatives to migrate my wordpress set up out of this architecture. Sure, it was fun and easy to set up something like this, but it is definitely not cost effective outside of Free Tier.

Using AWS Cost Calculator, I have estimated the above monthly cost to be close to USD $50 per month. Furthermore, both instances have very low CPU utilization and is just not the best solution post-free tier.

Stay tuned for a follow-up post on my next step.

Leave a comment

Your email address will not be published.