How to setup your website in Amazon Web Services (Part 2)

In this tutorial, we’ll see how to access EC2 instance or vm from local computer using command line interface (CLI). If you are using windows, then I recommend you to install ssh in your command line. This video might be useful for you.

Access EC2 instance:

If you are using Linux or OS X, most likely you already have ssh. Open your terminal or CLI and run the following command:

If you don’t see the version number, then install it.

In previous video, you’ve downloaded public key from Amazon Web Services. Keep it in a place (I prefer Desktop) where you can easily access for a now.

Open command line interface or terminal and go to the folder where you have saved the public key.

Run the following command to protect your private key file:

To access the vm or EC2, run the following command:

Here ec2-user  is the username. It can vary depending on the AMI or system that you selected in previous tutorial. is the “Public IP” that we got from our previous tutorial.


According to Amazon Web Services documentation:

For Amazon Linux, the user name is ec2-user. For RHEL5, the user name is either root or ec2-user. For Ubuntu, the user name is ubuntu. For Fedora, the user name is either fedora or ec2-user. For SUSE Linux, the user name is root. Otherwise, if ec2-user and root don’t work, check with your AMI provider.

After running the above command, if there is no error on the screen, then you are logged into the vm (EC2) successfully.


Install Apache PHP MySQL on EC2 server: 

After logging into the EC2 console successfully, run the following command to ensure that all software packages are upto date:

Above command will take some time to complete.

Now it’s time to install apache, php, mysql. Run

Start apache server:

If you want to start apache server when the EC2 or vm server starts, run:

The above command doesn’t show you any status, but it works.

Allow HTTP to access your web server: 

At this moment Amazon Web Services will not allow anybody to access our newly installed apache server that is HTTP server. To enable HTTP for all, we’ve to make some changes to our security group. Let’s do that now

Go back to your Amazon Web Services console (AWS) in your browser. Go to EC2 > Running instances.


If you scroll horizontally to the right of the table, you can see a “Security Groups” column at the end. Click on it ( red circle marked on the screenshot).


Screen Shot 2015-07-10 at 9.59.21 PM

In the next screen, click  Action > Edit inbound rules.


Screen Shot 2015-07-10 at 10.04.44 PM

A popup box will appear. Click on Add Rule button and then select HTTP from type dropdown box. You don’t have to change any other value. Keep them as they are suggested.  Click Save button.

Again Actions > Edit outbound rules and add new rule of HTTP the same way that you did for inbound rule.

Now, open your browser and type “Public IP”. You can see the following result, if everything goes okay.

Screen Shot 2015-07-10 at 10.06.17 PM


Wow, now your server is accessible from anywhere in the world. In next tutorial, I’ll show you how to upload files using FileZilla.

How to setup your website in Amazon Web Services (Part 1)

Setup Account at AWS: 

Go to and click on Sign in to the AWS console. Here you can get information about signing up. Amazon Web Services provides free tier for 1 year. The free tier includes 21 products and services. Such as Amazon EC2, Amazon S3, Amazon DynamoDB etc. Click here for details. You have to provide your credit card information to open account.

After creating account login to your Amazon Web Services (AWS) console by visiting

You will be redirected to dashboard, after you successfully login. The dashboard contains all the services that amazon offers. Some of them are free for 1 year (e.g. EC2, S3), others will charge.

Create new EC2 instance: 

Now, we’ll setup EC2 instance in our Amazon Web Services. It’s a very easy process and requires only a few steps.



1. Click on EC2 which is located at the top left of the dashboard.



2. Click on Launch instance.



3. In the next screen you will see a list of AMI (Amazon Machine Image) or system images. In short it’s the operating system that you are going to use in your virtual machine (vm) or EC2 instance. Some AMI are free.  You can select any one operating system such as Amazon Linux AMI, Red Hat Enterprise Linux, Ubuntu Server or even Microsoft Windows Server. We are going to select Amazon Linux AMI as free tier covers it.



4. In previous step you selected software. Now, it’s time to select hardware configuration. The page lists different Instances based on different numbers of CPU, memory and storage. If the left column you can see which instance is suitable for which purpose. For example, general purpose, compute optimized, memory optimized or storage optimized. I’m selecting t2.micro instance as it’s free. You can select any one that best suits your needs.

After selecting instance, click on “Review & Launch” button. We could select “Next: Configure Instance Details”. But for simplicity, we are not going there.


img55. In the next screen, click on Launch button which you can find at the bottom right corner. A popup box will appear. It lets you create or select existing key pair. The key pair contains

  • One private key that will be stored in AWS
  • One public key that you will download and store in your local computer. Keep it in a safe place. Because, you need this public key each time you login to your ec2 instance or vm.

After you download the public key and select on the acknowledge check box, launch instances button will be enabled and you can click on it.



6. Congratulations! Your first EC2 instance or vm is being setup. You can see the vm by clicking on View Instances button which is located at the bottom right corner.

When you click on View “Instances button”, you can se a list of instances (now it’s only one vm) in rows. If the setup process is complete, you can see a green circle in Instance column. Otherwise,  you will see yellow circle.

Notice, “Public DNS” and “Public IP” column. You need “Public IP” column’s IP address  for accessing the vm or EC2 instance from your computer. We’ll see that in next tutorial.



How to setup your website in Amazon Web Services (Intro)

Recently, I’ve moved my website ( to Amazon Web Services. To me it was easy and fun. It was also adventurous as I was doing it for the first time. Now, I’m going to share with you, how did I do it.


  • You should be familiar and comfortable to work with CLI (Command line interface).
  • You should be able to run ssh command from your command line (cmd for windows / terminal for linux or mac OS X.)

I’ve divided the tutorial into 4 parts.

Part 1: 

Setup Amazon Web Services (AWS) Account

Setup amazon EC2 instance.

Part 2: 

Access EC2 Service from terminal or command line prompt.

Install Apache PHP MySQL on EC2 server

Part 3: 

Access EC2 File system using FileZilla and upload files

Part 4: 

Add your domain name in Route 53

Change DNS of your domain name.

Check your website on server.