Image with the logos of WordPress and AWS, which is meant as a banner for the tutorial titled: Free WordPress Hosting: Using AWS to Host Your WordPress Site for Free

Free WordPress Hosting: How to Use AWS to Host Your WordPress Site for Free

Hosting a WordPress website for free on Amazon Web Services (AWS) is possible and easy. No adverts, almost zero downtime and high scalability. Let me show you how to do it.

Amazon Web Services (AWS) is a subsidiary of Amazon.com that provides a cloud computing platform for people to do things like host a website, store files (like pictures, MP3s, videos), perform machine learning processes etc. Today, I will show you how to host a full-fledged and advert-free WordPress website for free on AWS. We will be using something called AWS Free Tier. AWS itself is not free, but the Free Tier is a plan that allows you to use certain products in the AWS suite for a full year without paying anything. That’s music to the ears of anyone looking for free WordPress hosting!

Now AWS Free Tier is free, lasts for a year from the day you created an AWS account, gives access to some (not ALL) the products AWS has to offer and has monthly usage limits. Make sure you consult this page for the details of what you can and cannot do while using Free Tier so that you don’t incur any unplanned expenses. That said, the plan’s offering should be fine for your new WordPress website. If they are not enough (or they become insufficient as your website grows), your site may just be a baby kangaroo that has outgrown the snug pouch of its mother and has to step out into the world. That is, you will need to start paying for the AWS services that you use in excess of their Free Tier limits or that aren’t included in the plan.

Before we proceed, please make sure you have your desktop or laptop computer with you and have a steady Internet connection. In addition, you need to be somewhat familiar with using the command prompt/terminal of your computer. Finally if some terms used below are new to you, I have added links to a lot of them so that you can read more about them if you want, and you can always talk to me in the comments section.

Let us begin!

Table of Contents

  1. Create a SQL database using AWS RDS.
  2. Create an AWS Elastic Beanstalk environment for running the website.
  3. Configure AWS security groups and environment properties.
  4. Download WordPress.
  5. Configure and deploy your WordPress site.
  6. Install WordPress.
  7. Post Installation Comments.

Prerequisite: Create an AWS account

Head over to this page and create a free, new AWS account. If you already have an AWS account that is not up to 1 year old, you can use that too. Either of these will enable you to use AWS Free Tier. Afterwards, go ahead and sign in to the AWS Management Console. I suggest you set your desired region to EU Ireland (alias eu-west-1). The button for doing so should be in the top right of the Management Console. Using that region will make it easier for you to follow the steps below. However, you are free to use any other region you are comfortable with as long as you know how to manage it.

After signing up for or signing into AWS, please choose EU Ireland (alias eu-west-1) as your region. That will make it easier for you to follow the steps in this tutorial.

1. Create a SQL database using AWS RDS.

A WordPress website needs a MySQL database for storing data. We are going to create one using the AWS Relational Database Service (RDS).

  • Go to the Databases section of the RDS console.
  • You should see a table for listing your existing databases (which should be empty right now). Click the “Create database” button at the top-right of the table.
  • On the database creation page;
    • Under “Choose a database creation method”, select “Standard Create“.
    • Choose MySQL for “Engine Type”.
    • Choose MySQL 8.0.11 or later for “Version” (or choose any other version you want).
    • Under “Templates”, choose Free Tier.
    • Set “DB instance identifier” to sql-db-for-wp-website (or anything you like). This is just a tag for the database when it’s listed by AWS. It is not the database’s actual name.
    • Click “Credential Settings” to expand that section and make sure to change “Master username” to something different from “admin”. Once again, make sure you use a value different from “admin” for the master username of the database. Then check/tick the “Auto generate a password” box to ask AWS to generate a “Master password” for the database for you.
    • Leave the “DB instance size” section as it is. There isn’t anything for you to change there because the values have been determined by your Free Tier plan.
    • For “Allocated Storage” I recommend you use 30gb, but you can use any size that suites you. Just bear in mind that your max storage is limited by Free Tier usage limits.
    • Under “Storage autoscaling”, uncheck/untick the “Enable storage autoscaling” box.
    • For “Virtual Private Cloud (VPC)”, choose the one named Default VPC.
    • Click “Additional connectivity configuration” to expand it. Then set “Publicly accessible” to No to restrict access to your database to only AWS services inside your VPC. Then for “VPC security group” choose “Create new“, name the new security group as wp-website-sg and leave the other fields as they are. I’ll provide more details on AWS security groups later.
    • Click “Additional configuration”. Set “Initial database name” to wp_website_db. Underscores, not hyphens, are permitted in the database’s actual name. After that, I suggest you then read through other options in that section and modify them as you see fit. (I especially encourage you to enable deletion protection for the database.)
    • Finally, click “Create database“.
  • While the database is being created, you will be taken back to the “Databases” page. At its top, you’ll see a notification like the one below with a “View credential details” button. Click that button and take note of the credentials shown, especially the auto-generated database password. You won’t be able to view that password later, so make sure you save it somewhere that is safe and easy for you to access.
  • Next, you need to modify the security group we created earlier. A security group acts as a virtual firewall that restricts the traffic to and from the different services it is used for (e.g database, server, load balancer etc). So, you’ll need to modify wp-website-sg so that the database will accept requests from the other parts of your WordPress website (which we will create later).
    • Go to the Databases section of the RDS console.
    • In the “DB identifier” column, click sql-db-for-wp-website.
    • On the resulting page and in the “Connectivity and security” tab, scroll to the “Security group rules” section and click the name of the security group that has a “Type” of “CIDR/IP – Inbound“. That link will open in a new tab.
    • Scroll to the bottom of the new page, click “Inbound” and then click “Edit“.
    • In the resulting modal/popup, click “Add rule“.
    • For the new rule, set “Type” to MySQL/Aurora, “Protocol” to TCP and “Port” to 3306.
    • Then for “Source”, choose Custom and type “sg-” into the text field immediately to the right. You should see a list of security groups. Choose wp-website-sg. We will also be adding that security group to other parts of our app to enable them to connect to the database.
    • Click “Save“.

Great! Now that you have a database, let’s create the other parts that are needed to run your website.

2. Create an AWS Elastic Beanstalk environment for running the website

Apart from a database, a WordPress website depends on other software for its existence. These software include a web server, PHP etc. AWS Elastic Beanstalk (EB) is an AWS product that we will use to bring together these necessary resources and even extra resources like a load balancer and AWS Cloud Formation. So let us create an EB environment for our app.

  • Head over to the EB console.
  • Click “Create New Application” in the top right of the page.
  • In the resulting modal, set “Application Name” to wp-website-eb-app. You may also add a description and some tags if you wish.
  • Click “Create“.
  • After creation, wp-website-eb-app should appear as a dropdown button in the top left part of the page. Click the dropdown and then click “Create New Environment“.
  • Choose “Web server environment” and then click “Select“.
  • Leave the “Environment information” section as is.
  • For “Platform”, choose “Preconfigured platform” and then select PHP as your platform.
  • For “Application code”, choose Sample Application.
  • Click “Create environment”.

Creating a new EB environment will take a while. Thus, let’s move on to the next step while that process is going on.

3. Configure AWS security groups and environment properties

Moving on, you need to configure the security groups and environment variables available to our Elastic Beanstalk environment. We proceed as follows:

  • You need to add the wp-website-sg security group to the EB environment. There are different ways to do this, but the easiest one is to use the EB console as follows:
    • Open the EB console and click the application we created above to navigate to its management page (it should be named wp-website-eb-app-env).
    • Go to Configuration >> the Instances card >> Modify.
    • Under “EC2 groups”, choose both the security group to attach to the instances (i.e wp-website-sg) and the one created by that EB environment (its Group Name should have “AWSEBSecurityGroup” in it and its Name should be “WpWebsiteEbApp-env”).
    • Choose Apply, read the warning and then confirm the action.

Next, you need to use something called environment properties to pass important info to the EB instance e.g the domains, ports etc through which it can connect to the database.

  • Open the EB console and navigate to the Management page for wp-website-eb-app-env >> Configuration >> the Software card >> Modify >> the Environment Properties section. There you will see a form to use to enter information as key-value pairs.
  • For connecting to your database, define the following properties. If there are any of them you don’t remember (except the database password), go to the Databases section of the RDS console >> click the “sql-db-for-wp-website” identifier >> and check under either the Connectivity and Security section or the Security section.
RDS_DB_NAME: Name for your database. Should be wp_website_db.
RDS_USERNAME: The username you specified while creating the database.
RDS_PASSWORD: The password generated for your database (which I asked you to copy).
RDS_HOSTNAME: The hostname for your database. You should find it under "Endpoint" in the Database console.
RDS_PORT: The port your database is running on. Should be 3306.
  • Specify the values below as well for use in securing your app e.g encrypting passwords, validating log in sessions etc. Make sure you use a DIFFERENT value for each key below and that each value is at least 8 characters long and contains at least 2 uppercase letters, 2 lowercase letters, 2 numerical characters and 2 special characters.
AUTH_KEY: put your unique phrase here.
SECURE_AUTH_KEY: put your unique phrase here.
LOGGED_IN_KEY: put your unique phrase here.
NONCE_KEY: put your unique phrase here.
AUTH_SALT: put your unique phrase here.
SECURE_AUTH_SALT: put your unique phrase here.
LOGGED_IN_SALT: put your unique phrase here.
NONCE_SALT: put your unique phrase here.
  • All these properties will be made available to any app that runs in the said EB environment, so we will be supplying their keys to our WordPress app later on.
  • Click Apply.

Next, it’s time for you to download WordPress and prepare it for deployment.

4. Download WordPress

The installation files for WordPress are available as a TAR archive from wordpress.org. So you need to download that archive, extract it and give it some Elastic Beanstalk configurations as follows:

  • Open a terminal and navigate to a location that is easy for you to find, preferably your home directory (i.e ~).
  • Download WordPress version 5.2.3 by entering the command below. (If there is a newer version available when you read this, download that instead.)
~$ curl https://wordpress.org/wordpress-5.2.3.tar.gz -o wordpress.tar.gz
  • Extract wordpress.tar.gz as follows:
~$ tar -xvf wordpress.tar.gz
  • Rename the resulting directory to something that’s easier to read and navigate into it:
~$ mv wordpress wp-beanstalk

~$ cd wp-beanstalk
  • Download AWS’s sample config for Elastic Beanstalk environments and extract it into wp-beanstalk:
wp-beanstalk$ wget https://github.com/aws-samples/eb-php-wordpress/releases/download/v1.1/eb-php-wordpress-v1.zip

wp-beanstalk$ unzip eb-php-wordpress-v1.zip
  • When you are done, your wp-beanstalk directory should have the structure below. You can verify this yourself by running ls -l in the terminal. (NB: the blue-colored entries in the image below are directories and not ordinary files.)

Files and subdirectories structure for a WordPress app that is to be deployed to AWS.

5. Configure and deploy your WordPress site

Next, you need to configure the WordPress and Elastic Beanstalk files you have downloaded to get them ready for deployment to AWS. To do that, proceed as follows:

  • Ensure that the wp-config.php file inside wp-beanstalk has the same property names as the ones you set in Step 3 above. These include RDS_DB_NAME, RDS_USERNAME, AUTH_KEY etc.
  • The .ebextensions directory contains configs for our EB environment and the various resources within it.
    • In .ebextensions/dev.config, replace the placeholder IP address near the top of the file with the IP address of the computer you plan to use during the installation of WordPress in Step 6 (coming up next). This will ensure that no other IP address will be able to access your WordPress instance while you are installing it. That said, ENSURE you specify your IP address as a valid CIDR block e.g 127.X.Y.Z/32 or something. To know why, read more about CIDR blocks on this page. If you don’t, attempts to deploy the app will fail with error messages like "Creating security group ingress named: sshfromhome failed Reason: CIDR block 127.0.0.1 is malformed" or similar.
    • .ebextensions/efs-create.config is used to create an AWS Elastic File System (EFS) in your AWS Virtual Private Cloud for use in storing and running your core WordPress files. Check the VPC console for your default VPC and its subnet IDs. Note that if you are not using EU Ireland (alias eu-west-1) as your chosen region and your chosen region has less than or greater than 3 Availability Zones (AZs), you will have to customize .ebextensions/efs-create.config to reflect that.
  • Create a source bundle (basically a .zip file) using the contents of wp-beanstalk. To do this, enter the following in your terminal. Note that the resulting .zip file from the command below will be stored in the parent directory of wp-beanstalk (which should be your home directory if you’ve been following this tutorial to the letter). Doing this helps prevent you from mistakenly adding the source bundle for a previous deployment to the one for a new deployment.
wp-beanstalk$ zip ../wp-beanstalk.zip -r * .[^.]*
  • Upload the source bundle to EB to deploy the app using the following steps:
    • Go to the EB console >> click the card for wp-website-eb-app-env or WpWebsiteEbApp-env >> Upload and Deploy >> Choose File.
    • Select the source bundle you created earlier and click Deploy.
    • When the deployment is done, click the site URL (at the top of the page) to open the site in a new tab, which then leads us to the WordPress installation process…

6. Install WordPress

The browser tab you opened in the last step should show you a wizard for setting up and installing WordPress. If it doesn’t, first try to go to the EB console >> click the card for wp-website-eb-app-env or WpWebsiteEbApp-env >> click the app’s URL found at the top-right of that page. That should bring up the installation wizard. If that still doesn’t work, let me know in the comments section below.

Now, perform a standard WordPress installation. Since you’ve supplied a wp-config.php file in your source bundle, the installation process should have all the info it needs for connecting to the database, securing user logins etc.

7. Post Installation Comments

To round up, please ensure you don’t use wp-config.php to specify the environment properties for your WordPress installation, either now or in the future. Doing so is a serious security risk as some unethical person might get hold of that file. Furthermore, if you should use Git for your wp-beanstalk directory, future collaborators will be able to access your past wp-config.php even after you change or delete it. So stay safe and specify environment properties using the EB console.

Conclusion

Trust me, I know how difficult it is to find free, reliable, stable and ad-free WordPress hosting today. However, it is very valuable to be able to try out an idea or a new business for a while without incurring any significant costs just to see whether it will grow and at what rate it will grow. Therefore, using AWS Free Tier to host your website for free for a whole year is a great way to get your new blog, company, app or e-commerce store up and running with zero to little cost and using a great service like AWS. Here’s a toast to your success!

Finally, I hope you found this tutorial useful. If you did, please like and share it on Facebook, Twitter, Instagram and any other social media platforms you use. Similarly, if you have any praises, questions, comments and feedback concerning this tutorial, please share them in the comments section below. I will respond as accordingly. Feel free to check out my other tutorials too.

Asante kwa kusoma!

4 comments

  1. Hi. this site helped much more than the instructions in AWS, but one step that I can’t get passed is number 5. How do I configure the file. Where is the file? how do I upload the bundle if I can’t find it on my computer. I’m using windows 10 running Ubuntu app. Please help.

    1. Hi Robert! I am terribly sorry for replying so late. Are you still having difficulty getting past number 5? If yes, what exact file are you finding it difficult to locate and configure?

  2. Hi Folusho. Thanks for tutorial. I have noticed however that from step number 5 going forward you weren’t as detailed as in the previous steps, it appears as though you just wanted to get it over and done with.

    1. Hi Kat.

      Thanks for your feedback. I do think all of the steps in this article are as detailed as required- especially since this is the first time I will hear anyone say any step isn’t detailed enough. In fact I have taken a look at the steps you highlighted and I still think they are detailed enough. However if you are still having issues getting all the details you need from any of those steps, can you please tell me what those issues are so that I can try to help solve/clarify them? Thank you very much.

      Best regards,
      Folusho.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.