A set of sprinkle recipes for building a Rails/Unicorn server using Nginx and Postgres
Ruby Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This will set up a new ubuntu image with nginx, postgres and ruby in preparation for your rails app to be served by unicorn. All made possible by Sprinkle.


Copy the example config file to 'config.rb' and update it with your settings.

Then run the following:

bundle install
bundle exec sprinkle -v -c -s setup.rb


Assuming you're using capistrano for deployment and doing it the Github way, you should be able to cap deploy:setup as soon as this recipe has been run. Note that you'll need to do an nginx restart for it to pick up your unicorns. If you need some help with your capistrano config, check out my capistrano gist.

Here's an easy way to restart nginx from capistrano:

 namespace :nginx do
   desc "Restart nginx"
   task :restart, :roles => :app , :except => { :no_release => true } do
     sudo "/etc/init.d/nginx restart"

Here's an snippet for your database.yml that will configure postgres:

   adapter: postgresql
   encoding: unicode
   database: filter_production
   username: deploy
   pool: 5

That should be it! Contact me @mm53bar if you run into issues.

##What you get

  • nginx
  • postgresql
  • 'deploy' user for use with capistrano
    • your public keys added for easy and secure ssh
  • app environment set up at /var/applications/app_name/current
  • git
  • unicorn-focussed vhost file for nginx
  • redis
  • ruby-build
  • ruby installed from source and symlinked 'cause rvm/rbenv is painful with capistrano


I'm by no means a sysadmin expert. I've pieced this together over the past few months. If you have some better ideas, submit a pull request! Just be sure to figure out how to verify your steps using Sprinkle's verify method.