Deploy Rails on Amazon EC2 machine

How to deploy and run Ruby On Rails application on an EC2 machine ?
To copy the code form your local machine to an amazon ec2 machine, you may use the following steps. This tutorial supposes that you are using mysqlite as a database and that the port 3000 is opened in your EC2 machine.

1. Copy the code to your EC2 machine

$ rsync -avL --progress --exclude '*.log' -e "ssh -i key_to_my_machine.pem" ./local_application_path ec2-user@my_ec2_machine_ip:~/ec2_application_path/

2. Connect to ec2 machine and execute the following commands

$ ssh -i key_to_my_machine.pem ec2-user@my_ec2_machine_ip
[ec2-user@ip-x-x-x-x ~]$ cd ec2_application_path
[ec2-user@ip-x-x-x-x ~]$ bundle install
[ec2-user@ip-x-x-x-x ~]$ rake db:migrate
[ec2-user@ip-x-x-x-x ~]$ rails s

you can now visit your webApp at http://my_ec2_machine_ip:3000


1 comment: