Rails deployment checklist

At Good Dog Design, we manage a number of servers for our clients, and are frequently adding new ones. Whilst this process should really be scripted, until we do, this checklist should help cut a lot of the time that goes into setting up a new server.

These checklists are somewhat debian specific as we mainly run debian and ubuntu servers (on Slicehost if you’re curious), but many of the points can easily be adapted for your distro of choice.

Core server setup

  • Reset root password
  • Add a normal privilege (non-root) user sudo adduser {username}
  • Add this user to sudoers visudo
  • Login with this user
  • Ensure all relevant security/update repositories are present in /etc/apt/sources.list
  • Ensure all packages are up to date sudo apt-get update; sudo apt-get upgrade. If any packages are kept back, install them individually sudo apt-get install {package-names}.
  • Install and configure a firewall sudo apt-get install shorewall (see configuration at http://blog.matid.net/2007/2/1/securing-your-ubuntu-server [default config is located at /usr/share/doc/shorewall-common/default-config/]
  • Install essential build tools sudo apt-get install build-essential

Services setup

  • Install git sudo apt-get install git-core or subversion sudo apt-get install subversion
  • Install ruby sudo apt-get install ruby irb ri rdoc ruby1.8-dev libopenssl-ruby
  • Install rubygems from http://rubyforge.org/frs/?group_id=126 (don’t use apt-get)
  • Link gem to gem1.8 sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
  • Install relevant gems sudo gem install rails mongrel mongrel_cluster
  • Install postfix sudo apt-get install postfix
  • Install mysql sudo apt-get install mysql-server mysql-client libmysql-ruby1.8
  • Create a production database and user
  • Install memcache sudo apt-get install memcached; sudo gem install memcache-client
  • Install apache sudo apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils ssl-cert
  • Enable apache modules sudo a2enmod proxy_balancer; sudo a2enmod proxy_http; sudo a2enmod rewrite; sudo a2enmod deflate
  • Create an apache host config file in /etc/apache2/sites-available and enable it sudo a2ensite {sitename}
  • Create a deploy group sudo groupadd deploy and add any users to this group (sudo adduser {user} deploy)
  • Create a folder for the project sudo mkdir /var/www/project-url.com; sudo chown {me}:deploy /var/www/project-url.com
  • Create a mongrel user and group sudo useradd mongrel (don’t set a password for this user)
  • Install and configure monit sudo apt-get install monit

Rails setup

  • Capify rails project capify .
  • Install and configure the ExceptionNotifier plugin
  • Install any app-specific gems
  • Setup capistrano folder structure cap deploy:setup
  • Cold deploy cap deploy:cold
  • Ensure mongrels are running and site is accessible
  • Test regular deploys cap deploy
  • Setup any necessary cronjobs (I generally put them into an individual project file in /etc/cron.d/)
  • Set up log rotation