Basic EC2 Setup

Updated at 2015-07-25 09:57

This is a simple step by step guide to setup EC2 instance on Amazon Web Services.

Creating the Server

  1. Create an Amazon Web Services (AWS) account and login to AWS console.
  2. Change your location to where you want your server to reside.
  3. Go to EC2 and press Launch Instance.
    • Create T1 Micro instance. That is free for new accounts.
    • Select image to use in the install. Amazon Linux is a good choice.
    • When it asks about Tags, give tag named "Name" and give name like "myproject-server" or "artemis".
  4. Create new key pair file and name it "id_myproject-server". You do not want to lose this file as if you do, you get locked out of your server and need to restart it.
  5. Assigned security group cannot be changed after you launch the instance. Security group specifies what ports can be accessed from outside. Create new security group, name "myproject-sec" It is a good idea to set different security group for each project, but if you host multiple instances of identical server e.g. behind one load balancer, consider using one security group. Check that the security group has port 22 open for SSH connection.
  6. Starting up takes few minutes.
  7. After you connect to the server, use package manager to update it e.g. sudo yum update.

Connecting to the Server


  1. Download Putty And Puttygen. Use Puttygen to convert downloaded key pair file from .pem to .ppk.
  2. Launch Putty and enter server instance's public DNS address. You can get server instance public DNS address from the Instances page. It is the URL with "*" or something similar.
  3. Navigate to Connection -> SSH -> Auth in Putty and select to use the key pair file.
  4. Your key file have for SSH to work. Use this command if needed: chmod 400 id_myproject-server.pem.
  5. Click open and you should be connected to your new server.


  1. Add the .pem to ~/.ssh and setup it in ~/.ssh/config
  2. Use ssh command to connect.

If you can't access the server like this, check that the security group has port 22 open for SSH connection. Default groups should have them open though.

Connect Domain To EC2 Instance

Go to or other domain provider. Search for a domain you want and check if it is available. Good prices range from 5€ to 25€ per year.

You need to create Elastic IP, using those default EC2 IPs as target is a bad idea as they will change when the instance is terminated.

AWS Console
-> EC2
-> Elastic IP
-> Allocate New Address
-> Select EC2
-> Right click the address
-> Select your web server instance and press OK
-> Copy IP address found bottom middle
-> Use that in DNS

Amazon Route 53 DNS has servers in 17+ locations worldwide and it integrates easily with other Amazon services e.g. load balancer.

Create a Route 53 hosted zone for your domain e.g. ´´

Get resource record sets from the current DNS service for the domain that you are migrating. Add those record sets to your Route 53 hosted zone.

You should add:

  • A records which associate domain name with IP address.
  • MX mail server records.
  • CNAME records that routes subdomain to another address e.g. to and then both URLs show the same content. You can use different IPs also so you can have different servers under different subdomains. Or specify www in the name field and @ for the alias so it so points to

Update the name server records with your current DNS service to use the Route 53 name servers assigned to your hosted zone.

Allowing Public Access

Your newly created instance is blocking all non-terminal traffic by default. You need to open ports that you want to use. Opening port for HTTP:

AWS Console EC2
-> Go to Security Groups
-> Select your instance's security group
-> Select Inbound
-> Create new rule for HTTP, port should be 80 and source
-> If you created new security group, assign your instance to that group later.