Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy Rails Application on EC2

For the past week, I've been playing with the Rubber gem and can't seem to get it to work. I've decided it would be easier just to manually set up my EC2 instance. The problem is that I don't know how. Google hasn't been much help for a newb either. Any suggestions? It really is appreciated.

like image 425
Astephen2 Avatar asked Jan 18 '12 21:01

Astephen2


People also ask

How do I deploy AWS Rails app?

Deploy your application zip . Upload the source bundle to Elastic Beanstalk to deploy Rails to your environment. Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list.

What is the difference between EC2 and Elastic Beanstalk?

EC2 is Amazon's service that allows you to create a server (AWS calls these instances) in the AWS cloud. You pay by the hour and only what you use. You can do whatever you want with this instance as well as launch n number of instances. Elastic Beanstalk is one layer of abstraction away from the EC2 layer.


1 Answers

Sure.

  1. Create a AWS account.

  2. Decided what region you want to be in. Lots of things go into this decision, but worry about it later and just do a cheap one like Oregon or East.

  3. Make sure you are in the correct region at the top left.

  4. Then click launch server.

  5. At this point you have to pick a AMI. An AMI is basically the template you want to use when you boot your server. Amazon gives you some, but there are a ton in the community section. I am a CentOS guy so I usually search for a CentOS AMI. RightScale makes some good ones so you can search for one of those. Make sure you pick i386 or x64 depending on the size of server you want. There are two distinct types of AMI's, EBS backed and S3 backed. Really you should stick with EBS because you have some more freedoms, but there are reasons to use both that are beyond the scope of this answer. Look for EBS and you probably will be good. EBS is the block storage. Basically it is attachable harddrives for your instances. Since everything in the cloud is "virtual" and nothing is thought of in a physical sense, you have to think that way too. So if you want more storage, you can attach some EBS volumes later. One thing though, S3 backed instances go bye bye when you shut them down. The EBS ones will too if you have the delete on termination flag set, but with EBS ones you can "Stop" them as well as "Terminate" them.

  6. Select the size and availability zone. The zone is important if you are going to be setting up some kind of redundancy. Like if I have a master slave setup with MySQL I would put the master in one zone and the slave in another in case Amazon was having troubles that were isolated to one zone. But for this general purpose, don't worry about it.

  7. Advanced Instance Options. Just leave all this alone most likely it is fine. Some of the small things here you can set later like termination protection.

  8. Name it. Whatever.

  9. Make a SSH key. Striaght forward. The only way to login to an Amazon server will be with the SSH key you assign it. There are no user names or passwords.

  10. Security Groups. This is where you could get tripped up, well here and #5. But you should start off with creating a general security group call foo or whatever then adding the ports you want open on it. So if you want to ssh into it, which I assume you do, then open 22. If you want to use it for web then open 80 and 8080 or whatever. But be careful. I usually change my SSH port later to something random. And instead of putting 0.0.0.0/0 on it, I put my personal ip. But if you don't care that much just put 0.0.0.0/0 and open that bad boy to the world.

Then it will boot. As long as it all went as it was supposed to.

Now you can login. Just ssh -i thekey.pem thenwholehostname

Hope that helps.

There is this whole free tier you can use. http://aws.amazon.com/free/

Check that out. I would use that while you play with it.

I did all that from memory so I could have been off. ;)

like image 68
chantheman Avatar answered Sep 21 '22 16:09

chantheman