Deploying Rails Application on Amazon Ec2

Hello guys

Posting after a long time. But any ways below are the steps if you want to deploy a rails app on ec2 directly without using any 3rd party service providers

All the details mentioned below after for ubuntu so path might vary for other Linux flavours.

step 1 = Set java home. Ofcourse you need to have java installed and I assume that you already have it installed.

export JAVA_HOME
export PATH

Step 2 = login to amazon aws go to the account tab and download security credentials.  You will see 2 things

1) private key 2) certificate

Download them and store it on some path like /home/dhaval/cert or whatevery

Than export the keys and set it up with the following commands

export EC2_PRIVATE_KEY=/home/dhaval/cert/pk-2spdXHCQ4HDMJNCULJB5NA4JNLE7SWOR.pem
export EC2_CERT=/home/dhaval/cert/cert-2spdJXHCQ4HDMJNCULJB5NA4JNLE7SWOR.pem

Step 3 = Download api tools available on aws site

export it and set the path

export EC2_HOME=/home/dhaval/cert/ec2-api-tools-1.3-62308
export PATH=$EC2_HOME/bin:$PATH

Step 4 = set up ssh keys using the following commands

ec2-add-keypair gsg-keypair

Now save this generated kaypair in ~/.shh folder with name id_rsa-gsg-keypair

Step 5 = Start an instance using the command below

ec2-run-instances (ami instance name) -k gsg-keypair

Step 6 = Check status of the instance

check status with

ec2-describe-instances (instant name)


ec2-describe-instances i-10a64379

Step 7 = Authorization of network ports using commands as below

ec2-authorize default -p 22
ec2-authorize default -p 80

Step 8 = Connect to your instance using the command below

ssh -i id_rsa-gsg-keypair root@machine_name

Thats all once these steps are done you can see the instance running on the aws console.

Than install ruby gems + rails + other required gems and packages and you are set to go.

In order to upload your files you can use Capistrano or also you can ssh through ftp using the key specified.

Hope this helps. If you are stuck at any step do feel free to ask question and I shall get back to you.


Be Sociable, Share!