UPDATE: This is outdated due to the release of Capistrano 2… I will work on a new tutorial as soon as I have a project I need to deploy… 1-10-08

All righty then. Recently my firm ( SabreTech ) got a contract to write and deploy a fairly complicated web app for a local business. Immediately I asked my friend Xian to give me some deployment ideas, and he suggested I use nginx as my web server instead of Apache as well as Slicehost as my vps host provider…

So I setup my slicehost account and starting hacking. about a week later (five hours of work snuck in here and there), I’ve got my vps up and running smoothly. I’ve been using Capistrano for deployment for awhile, but I also wanted to use it to setup my server, and that is when I ran across deprec. Deprec is a nice little gem with a ton of capistrano recipes for setting up and deploying a server. It had some great recipes for deploying to Ubuntu , so I chose Ubuntu as my os for my new slice (vps).

Now I just had to write some of my own recipes for setting up and deploying with Nginx instead of Apache. That is where most of my time was spent. Below you’ll find my instructions and recipes:


  1. install the capistrano and deprec gems on your development machine
  2. cap your app, in the root of your app dir, run: cap -A
  3. setup deprec, from the root of your app run “deprec_dotfiles” which just creates a file in your user dir called .caprc, which contains the following line: require ‘deprec/recipes’
  4. your server must be running ubuntu (it should work on any debian based os though)
  5. your svn repository must be accessible by the same user listed in your deploy.rb
  6. nginx.conf , database.yml.production, and deploy.rb must exist and be configured in app/config (and checked into your repository)
  7. and finally, you need to take this file and append the contents to the bottom of your config/deploy.rb (these are the recipes i wrote)
  8. make sure and configure the mongrel settings in your deploy.rb


  1. log into your server as root and add a new user (the user you specify in your deploy.rb), set the password, and finally add to sudoers file
    1. useradd -m bobby
    2. passwd bobby
    3. visudo
  2. from the root of your app run: cap install_rails_stack_with_nginx
  3. the last one takes awhile, but when it is done run: cap svn_cache_credentials
  4. finally run: cap deploy_first_time
    1. (when it asks for mysql user password just press enter, unless you changed the mysql root password)