How to setup an AWS server instance

Beginners guide on how to setup their first web server using amazon web services.

Edited: 2016-01-03 18:29

In this tutorial we will show how you can setup an amazon web services (aws) server instance, and how you can connect to it from a linux terminal using SSH.

The AWS is increasingly becoming a popular way to host your websites, both for large professional companies, and for smaller private websites.

In this tuturial we will be setting up a server that runs Ubuntu as it's operating system, but it should also work with other systems - just make sure you use the correct logon information. For systems running Ubuntu the username when logging in will just be "ubuntu".

Setup an Ubuntu server instance

When you are logged in to your account, navigate to the Elastic Cloud (EC2) section, in this section you should be able to create a new server.

After clicking on this button you will be presented with different operating systems to choose from, select Ubuntu and click the select button.

Next you will be asked about the size of your instance, select the t2.micro instance and click on the Review and Launch button.

A final screen with a big warning is likely to show up, on this screen simply hit Launch, you will then be prompted to select an existing key pair or create a new key pair, you will be using this key when connecting to your server, so be sure to download the kay and save it somewhere that you can find it. Then hit the Launch Instance button in the prompt, and give your instance time to boot up. Etc.

When your instance has finished booting you can finally connect to it from the terminal.

Connecting to your instance from a linux terminal using SSH

When you have connected to your instance from the terminal, you can perform tasks such as starting, stopping and restarting your web-server, but you can also install updates and new software.

If for example you have setup a linux based instance, such as ubuntu, remote-controlling it is very easy, and can be done using the same commands as those you would use on a home installation.

To connect to your server, you should first change the permissions on the keyfile that you downloaded. This can be done by typing the following command:

chmod 400 /home/username/keyfile.pem

This assumes that you saved the keyfile to your user directory - also note that the actual path to your directory is not just:

/home/keyfile.pem

Even though that it may look like it from Nautilus.

After changing the permissions on the keyfile, you can finally connect to your server using SSH. Note.: that the username is that before the @:

ssh -i /home/username/keyfile.pem ubuntu@ec2.123.12.34.56.amazon.com

For ubuntu servers the username will be ubuntu. You can find the public dns name (the part after the @) in the description of your instance, on the AWS website.

Video tutorial on how to setup a server in AWS EC2

If you prefer watching a video on how to do this, this video shows how to both setup the server, and how to connect to it after setting it up.