Introtoec2vid_2

Amazon.Development server installation on EC2 (quick quide)

When you work with a team, and on some reason do not want to have own server, you can use EC2 from Amazon. Clouds become more and more popular and, of course, cheaper. At this moment, Amazon allows you to use EC2 micro instance about 1year for free. If you will not try to load it heavy. To check restrictions and get more info about it, visit aws.amazon.com

Recently, I decide to create own development instance. So, I decided to make quick installation quide how to create development server quickly. I suppose that you already have account on Amazon AWS. If not, you can register here.

I had a choose from Google VPS and Amason EC2, but decided to use Amazon, because its

  • first year is free
  • if project is not heavy loaded, its cheaper than Google VPS.

In order to make installation faster, I decided to use Ubuntu Server 14.04 LTS (HVM):

EC2.1

Amazon have nice and user-friendly user interface, so you won’t be confused.

Next step, lets select instance type. Micro instance is for free, so lets select this one:

EC2.2

Then we can select disk space and type. You can select up to 30GB for free.

After selection disk space and type, we  can make basic settings for SecurityGroup:

EC2.4

When you choose Source «MyIP», you should understand: if your IP is not static, you will have to update it every time if changes.

EC2.5

And on last step you can select/generate keys for connection to server. DO NOT forget to download this key. Otherwise you will not be able to connect to your instance.

So, we made basic operations and successfully created our Amazon EC2 Instance and you have your private key, nice, lets continue.

  • put your key to ~/.ssh/ folder and execute command: $chmod 400/path/to/your/private/key.pem
  • find IP of your instance, you will need it for connection

Your IP you can find here:

EC2.IP

Btw, if you press button «Connect», you will get help, how to connect to instance.

Then lets create ssh alias for quick connection to Amazon. As you see, I have IP 54.191.103.180, so I’ll use this one in example, and you will use our own:

  1. $sudo vim ~/.ssh/configs
$sudo vim ~/.ssh/configs

And create alias:

  1. Host amazon
  2.  Hostname 54.191.103.180
  3.  IdentityFile /path/to/your/private/key.pem
  4.  Compression yes
  5.  ForwardAgent yes
  6.  User ubuntu
Host amazon
 Hostname 54.191.103.180
 IdentityFile /path/to/your/private/key.pem
 Compression yes
 ForwardAgent yes
 User ubuntu

Nice, lets connect to our new server:

  1. $sudo ssh amazon
$sudo ssh amazon

If you cant connect, try this:

  • check IP address
  • check permission of private key file.
  • check SecirityGroups in Amazon EC2 Management Console: SecurityGroups->Select Your Group->Inboud tab->Check if you have SSH in your settings:

EC2.Security.SSH

 

If you want to use web server , you must allow port 80 in SecurityGroups:

EC2.Security.Add_HTTP

Additionally we should add swap file. Micro instance has 1GB of memory, so I’m sure I may have «out of memory» errors. Lets add +1GB(1024MB) swap:

  1. sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
  2. sudo /sbin/mkswap /var/swap.1
  3. sudo /sbin/swapon /var/swap.1
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

Btw, you can set another swap size, but I do not see any sense to make it bigger.

If you want to enable it by default after reboot, add this line to /etc/fstab:

  1. /var/swap.1 swap swap defaults 0 0
/var/swap.1 swap swap defaults 0 0

Instance is created and launched, ports are open, we can connect to it using SSH, so first step is completed.

Next steps are:

 

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterEmail this to someoneShare on LinkedIn

Aboutalex

Вэб-программист. Занимаюсь разработкой cервисов, написанием API, вэб-приложений. Интересна разработка приложений для высоконагруженных систем, анализ данных..

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

три + 3 =