Skip to content

Instantly share code, notes, and snippets.

@umar-siddiqui
Created January 21, 2016 10:27
Show Gist options
  • Save umar-siddiqui/b4954c62761c937bf89c to your computer and use it in GitHub Desktop.
Save umar-siddiqui/b4954c62761c937bf89c to your computer and use it in GitHub Desktop.
RailsServerSetupCapistrano

Rails Setup

Configure ssh

  • Add ssh key to server cat ~/.ssh/id_rsa.pub | ssh bill@xxx.xxx.xxx.xxx -p 4321 'cat - >> ~/.ssh/authorized_keys'

  • Change permission of ssh folder sudo chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh/

Install Apache and Dependencies

  • Update repositories sudo apt-get update

  • Setup locals sudo apt-get install language-pack-en sudo locale-gen en_US en_US.UTF-8 en_CA.UTF-8 sudo dpkg-reconfigure locales

  • Install basic dependency packages sudo apt-get install apache2 curl git build-essential zlibc zlib1g-dev zlib1g libcurl4-openssl-dev libssl-dev ruby-dev apache2-dev libapr1-dev libaprutil1-dev libreadline6 libreadline6-dev

sudo apt-get install build-essential libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

Install MySql Server

sudo apt-get install mysql-server

Install MongoDB

https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

Incase you get any warning while staring mongodb shell https://docs.mongodb.org/manual/tutorial/transparent-huge-pages/

Installing ruby on server

Install Passenger

Follow all steps given in below link

https://www.phusionpassenger.com/library/install/apache/install/oss/trusty/

Setup Capistrano

Setup capistrano inside rails project to automate deployment

  • Add following to gemfile

    group :development, :test do
      gem 'capistrano', '~> 3.4.0'
      gem 'capistrano-rbenv', '~> 2.0', require: false
      gem 'capistrano-rails',   '~> 1.1', require: false
      gem 'capistrano-bundler', '~> 1.1', require: false
    end
    
  • Run setup command inside rails project cap install

  • Modify cap file

    require 'capistrano/setup'
    require 'capistrano/deploy'
    require 'capistrano/bundler'
    require 'capistrano/rails/assets'
    
    # Load custom tasks from `lib/capistrano/tasks` if you have any defined
    Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
    Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
    Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }
    
  • Update deploy file https://gist.github.com/ketan-ghumatkar/fdeb101ab44ece1d2084

  • Deploy to instance cap production deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment