Mallow's Blog

How to Configure & Install WordPress in AWS Instance

Today there is surge in the hosting service providers and a large number of companies are providing shared hosting services. Majority of the small business websites opt in for the shared hosting services. In this there will be a monthly premium to be paid and you will get a predefined set of features. But if you need some advanced options and thinking of scaling, optimising and using your website for advanced features then Amazon’s Cloud is an option worth considering.

One of the significant feature of the service is that it is easy to upgrade. Creation of a server machine won’t even take a lot of time. Also the biggest advantage in Amazon cloud is that you can instantly upgrade the servers to handle the jump in traffic any time. Balancing the surging load is not a complex task in here.

If your site traffic is increasing tremendously then you need to upgrade your shared hosting services or move on to the specialised hosting services. It costs you a fortune. Amazon on the other hand gives you a great deal in designing a server architecture to match your needs. The beauty in it is you can do that on your own rather than hiring a network operations team in the most efficient way possible. This is the way most of the facebook developers have built their servers.

Now the thing with WordPress is that it restricts some of the operations. So if you ever had a thought of rebuilding or rejuvenating your site with PHP or MySQL, you can do it by yourself. You don;t have to ask your web hosting company. You can install the software of your choice, just as you do in your own server.

So, Be it WordPress or any other CMS, Amazon is the perfect choice for the site based on the traffic it receives. Also it depends on the value you give in configuring your server to meet your needs.

Let us see in detail about creating an Amazon Wen services account and how to install WordPress in it.

Step 1 – Create an Amazon Web Services Account

Before starting to use Amazon’s cloud for your web hosting, you need to create an account with Amazon Web Services (AWS). Go to and click Sign Up Now button.

Signup - AWS

If you have already used, you can use your existing e-mail and password to login to AWS. If not you can also create a new account by choosing “I am a new user.”

Creating a new id

At this stage, you have to give them your credentials such as contact info and credit card number for billing purposes of the services. Everything apart from creating an account costs you in this. The payment is on a hourly basis for the running server. But the actual price varies as it is a bit more complex than just calculating the running server. So you need to be careful in your price calculations before leaving the servers unattended to avoid the bills that bites your pocket.

Building the WordPress setup shouldn’t take much time. We will stop everything when we’re finished, so the price for completing the tutorial will be nearly zero Dollars.

Step 2 – Launch Your First Server Machine

Setting up the server consists of two parts:

Application server is hosted on Amazon’s Elastic Computing Cloud (EC2), running Apache and PHP, with WordPress installed on it.

MySQL database hosted on Amazon’s Relational Database Service (RDS).

There is another cheaper option is to manually install the MySQL server on the machine with Apache and PHP. This method is bit difficult than the previous one but saves you a few dollars. We will see the Relational Database Service as it eases your work. Also in this way you don’t have to worry about the backups, database maintenance as Amazon will take care of that. Also Amazon will take care of the additional security too.

Let us start by creating the first application server instance.

Click on the EC2 tab in the AWS Management Console. As this will be your first time using the EC2 service, you will need to separately sign up. Click on the “Sign Up For Amazon EC2″ button as shown below

EC2 - Signup

Amazon will verify your identity by placing a call to your phone for security purpose. This process is automated: you type a code from the web page into your phone and, once the system has verified that the codes match, you will be then redirected to the next page.

When you are done with the sign up process, return to the Management Console and the EC2 tab. Click on the Launch Instance button in the page as shown below.

Launch Instance

A popup with a list of Amazon Machine Images (AMIs) opens.

(AMI’s are basically the snapshots running computers)

Most consist of an operating system and a few utilities, but you can also create AMIs with as much complexity as you wish for — even containing your full application, ready to be started on a virtual machine with just a click.

In here we will pick the most basic option: “Basic 32-bit Amazon Linux AMI 1.0.” Click on “Select” next to the AMI and you are ready to go.

After selecting the AMI, our next step is to decide what kind of hardware we will use to run it. Depending on whether you picked a 32-bit or a 64-bit AMI, you will see a different list, the 32-bit AMIs offering the cheaper options.

For testing purposes, we don’t need much of a memory or processing power, so we will start with a Micro instance. Select the instance type and click “Continue.”

In the next screen, the defaults do just fine. Click “Continue.”

If you have many machines performing different roles, there is a good chance to mixup the machines. Hence naming the machines will help is tracking the work. In this particular case naming is not too important, as we will run only one EC2 instance, but it is better to name it for future reference. Enter your desired name and click “Continue.”

Next, you will be asked to create a key pair file for securely connecting to the machine. This key replaces a password when connecting to the machine with SSH. Name your key pair file, and click on “Create & Download your Key Pair.” Copy the key pair file to a safe location (A good place, if you are on a Unix system such as Mac OSX or Linux, is ~/.ssh). After copying the file, change its permissions to 400:

chmod 400 wordpress_demo.pem

If you are using Windows, you probably use PuTTY for SSH. PuTTY uses its own key format (ppk), so you will need to convert the key to that format by using the Puttygen tool available at the PuTTY download page.

After you’ve created the key pair, you will still be asked to configure the firewall for your new machine. By default, no one is allowed to connect to the machine — every port is closed. Let’s open ports 22 (SSH) and80 (HTTP), so that we can configure the machines over SSH and access the blog from the browser. Select the type of connection from the drop down list at the bottom of the popup and click on “Add Rule.” When you are done with the setup, click “Continue.”

Review the configuration and if everything is fine then click “Launch” button.

Now the server machine is launching! Close the popup in order to return to the dashboard. At first, you’ll notice that the instance’s status is set to “pending,” and within a couple of minutes it switches itself to “running.” This means the server is up and running — you can start of the operations now.

When the machine is running, it can be accessed through the defined ports in the firewall configuration. Let’s use SSH to connect to the machine and finish its setup by installing Apache, PHP, the MySQL extension to PHP, and finally WordPress.

Step 3 – Install Required Server Software

In this we will see the steps to install the required server software. Firstly right click on the particular name of the machine and select connect from the drop down list. A popup will open with an SSH Command.

Highlight the command, and copy it to a console if you are using a Mac or a Unix machine. The command will be similar to the following:

ssh -i wordpress_demo.pem root@ec2-…

If you saved your pem key to ~/.ssh, update the path in the command. Also, you need to change root into ec2-user — Amazon hasn’t yet updated the command to match its new AMI setups that don’t allow connecting with the root user.

If you are on Windows, or prefer to use a more graphical SSH application, simply copy the name of the machine and open it in your SSH application of choice. Remember to use the user name ec2-user and the related key pair file (wordpress_demo.pem).

Once logged in, you can use the virtual machine just as you would use any Linux machine.

To install software, we will use an easy to use installer called Yum. First, to install the Apache web server, type the following command:

sudo yum install httpd

The installer asks you to confirm the package to install and possibly some other steps as well. Reply with “Y” to every question, and, in no time at all, you will have Apache installed.

Next up, PHP:

sudo yum install php

And the same for the MySQL extensions:

sudo yum install php-mysql

this marks that the setup is done and we are ready to test Apache. Start it with this command (you can later replace “start” with “stop” or “restart” depending on what you want the web server to do):

sudo /etc/init.d/httpd start

The web server is up, and you can test it by copying the URL of the machine to your browser:

Step 4 – Create the Database Machine:

Before installing WordPress, we need a database. Setting up a database using RDS is simple process.

In your AWS console, switch to RDS tab. As you have never used this particular service before, you will be asked by AWS to enable it. This time, the process is much faster and simpler than when you enabled EC2. Click on “Sign Up For Amazon RDS” to get started.

Follow the process through and, when you are finished, head back to the RDS tab in the AWS console. The screen you will see looks a lot like the EC2 console we used in the previous step. Click “Launch DB Instance.”

In the popup that opens, you can choose the properties for the database server to start, such as the server instance and storage space to allocate. Let’s pick the smallest values as they are more than enough for our simple test.

Pick a name for you database server and the root user on it. I used “wordpress-db” as the database server name and “root” / “rootpass” as master login. Not the most secure of options, mind you, but this machine is not intended to last for long, so it’s okay in this instance.

After setting up the database server information, you will be asked to define a default database to be created on the server. We will call it “wordpress” to follow the WordPress conventions. The rest of the settings on this screen can be left untouched.

On the next screen, you can define settings for database backups. For now, leave the values to their defaults and click “Continue.”

After verifying the settings, click “Launch DB Instance.”

Creating a database instance takes quite a bit longer than creating the EC2 instance, but after about five minutes of waiting, you should see the database instance as “available” on the instances tab.

Click on the instance to see more data about it, then copy the “endpoint” value. This is the URL of the database server that we will use in the WordPress setup.

There is one more step before we can move on to installing WordPress: we need to configure the firewall for this database so that the application server can access it.

Still on the RDS tab in the AWS console, click on “DB Security Groups.” You will see that there are no authorizations yet:

To give our application server access to the database, we need to authorize its security group to this database security group. Select “EC2 Instance” from the drop down list below “No Authorizations” and enter the name of the security group (“wordpress_app_server“) and your Amazon Account ID to the two text fields that appear next to the drop down list.

The account ID is hidden quite deep in the AWS settings: you’ll find it by first clicking the “Account” link at the top of the page, and then the “Security Credentials” link on the page that opens.

After you’ve entered the required information and clicked “Add,” you will see the security group as authorized. We are ready to install WordPress.

Step 5 – Install WordPress:

If you are not connected to the application server anymore, open an SSH connection to it again. We’ll start by downloading WordPress on the machine. By default, Apache is configured to look for HTML files from/var/www/html/, so let’s download WordPress to that directory.

view plaincopy to clipboardprint?

cd /var/www/html

To make things easier in the future, we will change ec2-user to be the owner of that directory:

sudo chown ec2-user .

You can download WordPress to your own computer and upload it from there using SCP, but I find it easier to download it directly to the Amazon machine using wget:

view plaincopy to clipboardprint?


This way, the WordPress package goes straight to its final location and all you need to do is to unzip it:


We are about ready to start configuring the blog. As our last step in the command line, change permissions of the wordpress directory that was just created so that the installation script can create the wp-config.php file:

chmod o+w wordpress

Now, open the WordPress URL in your browser (The URL of the EC2 instance followed by /wordpress). Click on “Create a Configuration File” and then on the next page “Let’s go!”

You will end up on a page for entering the database settings. Enter the database name, user name and password, and the URL of the RDS instance. Then click “Submit.”

(image 27)

You are almost set. Configure the rest of the blog details to finish the installation and enjoy your newly created blog.

You have successfully installed WordPress in the cloud!

Step 6  – Stop Everything

As I mentioned at the beginning of this tutorial, AWS billing is based on the hours of usage, so to make sure you are not billed for time that you are not really using, make sure to stop everything once you are done testing.

First, stop the EC2 instance by selecting it from the admin, right clicking on it and choosing “Stop.” If you later decide to start the machine again, all you need is to click on “Start” in the same drop down list and the machine will resume from where you left it.

Stopping the database is just as easy, with the exception that you can’t resume the database again. That’s not so nice, but luckily you have the choice to save a snapshot of the data while stopping the database. You can later use this data to recreate the database setup whenever you need it again.

On the RDS tab, right click on your database instance and select “Delete.”

Verify that everything is stopped and log out of the AWS console. Your blog is gone, just as fast as it started.


R. Rajesh
Networking Team,
Mallow Technologies.

Leave a Comment

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