If you want to set up a rails application on an amazon´s EC2 Instance, this might be something for you. Please note, that this instruction only covers the installation of rails and all its dependencies. If you want to use rails for production, you should also install an apache.
If not already done, go to Amazon's EC2 Dashboard and launch a new Ubuntu Instance.
After that, you get a permission file
*.pem
. Save that on your disc and restrict the permissions to600
:chmod 600 ~/myinstance.pem
Connect to the server via ssh
ssh ubuntu@ec2-x-x-x-x.compute-1.amazonaws.com -i ~/myinstance.pem
Replace the -x-x-x-x with your real instance name and
~/myinstance.pem
with the path to your .pem-file
All following steps take place on your ubuntu machine. First of all, update the package manager
sudo apt-get update
Install ruby
sudo apt-get install ruby-full build-essential
Install rubygems
sudo apt-get install rubygems
Install rails
sudo gem install rails
Install sqlite and the ruby gem
sudo apt-get install libsqlite3-dev sudo gem install sqlite3-ruby
Install nodejs
sudo apt-get install nodejs npm
Create a rails test application
mkdir home/ubuntu/www cd home/ubuntu/www rails new testapp
Start the rails server
rails server
Please note, that you should not use this server in production. This just a test, to see if rails runs on your EC2 instance.
Finally, set up the security group in your AWS console, so that port 3000 is activated. In your AWS console click on 'NETWORK & SECURITY > Security Groups'. Choose the security group of your instance. In settings klick on 'Inbound' and create a new rule:
TCP 3000 0.0.0.0/0
Don´t forget to press 'Apply Rule Changes' when done!
Go to
ubuntu@ec2-x-x-x-x.compute-1.amazonaws.com:3000
. There you should see the rails default screen!Next steps: Set up an apache to deliver your application.