Hosting WordPress on AWS

Janvi Ajudiya
8 min readAug 7, 2021

The Charotar University of Science and Technology did not stop worrying about their students development in midst of COVID-19 pandemic as they provide chance to their students to make company experience by providing internships into various companies. As a part of it, I am able to complete my internship successfully by doing some assigned tasks by company.

Hello Folks, in this blog of mine, I would be talking about how you can host your WordPress site on AWS using AWS Elastic Beanstalk and you can also do it via EC2 instance also. But I will talk about hosting WordPress on AWS using Elastic Beanstalk. For this, which technology will be used, what is wordpress, what is AWS Elastic Beanstalk, some basic knowledge is required and below you can find these all.

Technology used :

Amazon Web Service(AWS Elastic Beanstalk, Amazon S3, Amazon RDS, AWS IAM)



WordPress (WP) is a free and open-source content management system (CMS) written in PHP and paired with a MySQL or MariaDB database. Features include a plugin architecture and a template system, referred to within WordPress as Themes. WordPress was originally created as a blog-publishing system but has evolved to support other web content types including more traditional mailing lists and forums, media galleries, membership sites, learning management systems (LMS) and online stores. WordPress is one of the most popular content management system solutions in use. WordPress has also been used for other application domains, such as pervasive display systems (PDS).

AWS Elastic Beanstalk:

With Elastic Beanstalk, you can quickly deploy and manage applications in the AWS Cloud without having to learn about the infrastructure that runs those applications. Elastic Beanstalk reduces management complexity without restricting choice or control. You simply upload your application, and Elastic Beanstalk automatically handles the details of capacity provisioning, load balancing, scaling, and application health monitoring.

Elastic Beanstalk supports applications developed in Go, Java, .NET, Node.js, PHP, Python, and Ruby. When you deploy your application, Elastic Beanstalk builds the selected supported platform version and provisions one or more AWS resources, such as Amazon EC2 instances, to run your application.

AWS Elastic Beanstalk

Amazon S3:

Amazon Simple Storage Service (Amazon S3) is storage for the Internet. It is designed to make web-scale computing easier. It is an object-level storage. Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, and inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites.

Amazon S3 and other storage options

Amazon RDS:

Amazon Relational Database Service (or Amazon RDS) is a distributed relational database service by Amazon Web Services (AWS). It is a web service running “in the cloud” designed to simplify the setup, operation, and scaling of a relational database for use in applications. Administration processes like patching the database software, backing up databases and enabling point-in-time recovery are managed automatically. Scaling storage and compute resources can be performed by a single API call to the AWS control plane on-demand. AWS does not offer an SSH connection to the underlying virtual machine as part of the managed service.

Amazon RDS with its read replica in other AZ

AWS IAM(Identity and Access Management):

AWS Identity and Access Management (IAM) enables you to manage access to AWS services and resources securely. Using IAM, you can create and manage AWS users and groups, and use permissions to allow and deny their access to AWS resources. IAM is a feature of your AWS account offered at no additional charge. You will be charged only for use of other AWS services by your users.

AWS IAM(Identity and Access Management)
How IAM works

Step-by-step Procedure :

Here, We are going to serve a wordpress application from Elastic beanstalk, using Amazon RDS for MySQL database and S3 for static content.

The whole work will be done in 5 phases.

  1. Creating RDS instances
  2. Create S3 bucket for static content
  3. Creating source bundle
  4. Create Elastic Beanstalk application
  5. Link Elastic Beanstalk application to RDS instance

Create RDS Instance:

  1. On the RDS dashboard, In the sidebar click on ‘databases’ and click on the create database.

2. Select ‘MySQL’ as an engine type.

3. Name the database , create master username and master password.

4. Specify Instance specifications :

DB instance class : Choose d2.t2.micro

Multi-AZ deployment : Choose no

Storage type : Choose General Purpose (SSD)

Allocated storage : Enter 20GB

5. Configure Advanced Details: Select publicly Access as ‘no’ and create a new Security Group.

7. Click on the Create Database.

As we have set, publicly accessible to ‘No’ means the database will only be accessible by the instances in the same VPC security group.

Create S3 Bucket for Static Content

  1. Go to the S3 dashboard. Click on ‘Create Bucket’.
  2. Give the name of the bucket and Select the region.

3. Click on Create bucket.

Create a new IAM Policy:

  1. Go to the IAM dashboard, select “Policies” from the menu at left , and click the “Create Policy” button.

2. Select the “JSON” tab and copy and paste the following. Replace “YOUR-BUCKET-NAME” with your S3 bucket name.

"Version": "2012-10-17", //This is versioning internal to AWS.
"Statement": [
"Effect": "Allow", //We want to allow the following actions on the resource.
"Action": [
], //Allow the user to get, put, and delete files in our bucket.
"Resource": [
"arn:aws:s3:::YOUR-BUCKET-NAME", //Allow the actions on the bucket itself.
"arn:aws:s3:::YOUR-BUCKET-NAME/*" //Allow the actions on all files within the bucket.

3. Click the “Review Policy” button at bottom and create a name for your policy.

Create a new IAM user

  1. Go to the IAM dashboard, select “Users” from the menu at left , and click the “Add User” button.

2. Enter username. Select Programmatic Access.

3. Select Attach existing policies directly and add the policy you created in the previous step.

4. Click on ‘Next: Review’ and Click on ‘Create User’.

Create your source bundle

Download WordPress from following link:

Install plugins

We need to install the WP Offload S3 plugin that we’ll be using to store media files in S3.

The WP Offload S3 plugin requires the Amazon Web Services plugin. Download this plugin as well, unzip the package, and save to wordpress/wp-content/plugins/.

Create wp-config.php

Delete wordpress/wp-config-sample.php and create a new file.


// AWS configuration for WP Offload S3.
// MySQL configuration.
define('DB_NAME', $_SERVER['RDS_DB_NAME']);
define('DB_HOST', $_SERVER['RDS_HOSTNAME'] . ':' . $_SERVER['RDS_PORT']);
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
// Authentication keys and salts.define('AUTH_KEY', $_SERVER['WP_AUTH_KEY']);
// Other WordPress defaults.$table_prefix = 'wp_';
define('WP_DEBUG', false);
if (!defined('ABSPATH'))
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');

Create Elastic Beanstalk configuration files

Create a new folder wordpress/.ebextensions. Elastic Beanstalk looks for configuration files in this directory when deploying an application.

Create a new file wordpress/.ebextensions/env.config:

AWS_ACCESS_KEY_ID: 'placeholder
AWS_SECRET_ACCESS_KEY: 'placeholder'
WP_AUTH_KEY: 'placeholder'
WP_SECURE_AUTH_KEY: 'placeholder'
WP_LOGGED_IN_KEY: 'placeholder'
WP_NONCE_KEY: 'placeholder'
WP_AUTH_SALT: 'placeholder'
WP_SECURE_AUTH_SALT: 'placeholder'
WP_LOGGED_IN_SALT: 'placeholder'
WP_NONCE_SALT: 'placeholder'
RDS_DB_NAME: 'placeholder'
RDS_HOSTNAME: 'placeholder'
RDS_PORT: '3306'
RDS_USERNAME: 'placeholder'
RDS_PASSWORD: 'placeholder'

Create Elastic Beanstalk application

  1. Go to the Elastic Beanstalk dashboard and click “Create New Application” in the upper right.

2. Enter name and key value details.

3. In platform Select ‘PHP’. Choose Upload your own and select the wordpress/ file you created earlier. Click the “Next” button.

Hosting Wordpress on AWS

4. Select below Environment Information.

Environment name Enter a name for your environment. Can be anything.

Environment URL Can be anything unique to AWS.

Click the “Next” button.

5. In Configuration Details, Choose t1.micro instance type.Leave the rest of the default values and click the “Next” button.

6. Review your selections and click the “Launch” button.

Link Elastic Beanstalk application to RDS instance

Find your RDS security group:

First, go to the RDS dashboard, click on “Instances” in the menu on the left, and select your instance. Scroll down to the “Details” section. Under “Security and Network” you’ll find the instance security groups.

Allow inbound access:

In the security group settings, click on the “Inbound” tab and click the “Edit” button. Add a new rule to allow members of the security group to access the database.

Set the type to “MYSQL/Aurora”, the protocol to “TCP”, and the port range to “3306”.

Add Elastic Beanstalk to security group:

Go to the Elastic Beanstalk dashboard and click on your environment. Click on the “Configuration” link on the left . Click on the cog on the “Instances” panel.

In the “EC2 security groups” field, add a comma and the name of your RDS security group . Scroll down and click the “Apply” button.

Set up WordPress

Once your environment has restarted when you go to the site you should be guided through the WordPress installation. Note that you will not be asked to configure the database since that’s already been completed.


Output of how it looks like

I hope you guys liked this blog. Visit the profile for more blogs. If you like this blog, then do not forget to give a clap😄.