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.

Leave a Reply