Skip to content

Instantly share code, notes, and snippets.

@AKNiazi
Created October 1, 2014 05:51
Show Gist options
  • Save AKNiazi/fe7d3b9e26db42ac2be4 to your computer and use it in GitHub Desktop.
Save AKNiazi/fe7d3b9e26db42ac2be4 to your computer and use it in GitHub Desktop.
Steps to deploy Ruby on Rails Apps on Amazon EC2 with postgresSql
1. Log in to the AWS console. (First you should create account on Amazon)
2. Create key pair
3. Create elastic IP
4. Make new instance of the aws manually.
5. Create the ppk key from the .pem key.
6. Login to the putty give the public ip to in the host and also add the putty key file in the auth/ssh
7. Provide ubuntu as the user name.
Now after the login
A- Install required ruby version using RVM
B- Install required gem sets
C- Install rails
D- Install postgres (https://help.ubuntu.com/community/PostgreSQL)
You will need to create the password and database
E- install git
All above steps are simple.
F- Install capistrano on local machine and follow capistrano documentation on github to write deploy.rb and procduction and staging.rb
After these step we need to login to putty terminal again and install
link (https://www.digitalocean.com/community/tutorials/how-to-setup-a-rails-4-app-with-apache-and-passenger-on-centos-6)
1. apache-2 (sudo apt-get install apache-2)
2. passenger gem (gem install passenger)
3. passenger-install-apache2-module This will guide you to the rest of the steps. If it asks to increase swap size. please do it.
sudo dd if=/dev/zero of=/swap bs=1M count=1024
sudo mkswap /swap
sudo swapon /swap
link: (http://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger)
4-give appropriate permissions on var folder
6- Virtual host binding with project code and IP/hostname
The next steps are:-
1- Adding project code at the appropritae place in apache i.e. inside /var/www
2- Assigning the folder write permissions
3- Adding virtual host entry in apache2.conf
- restarting the server
sudo service apache2 restart
LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/ubuntu/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
PassengerDefaultRuby /home/ubuntu/.rvm/gems/ruby-2.1.2/wrappers/ruby
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment