Quick intro in angry split personality QA format:

Ya What? Unicorns? Sinatra?? Nuggex??? You're just stringing random words together! Badly!

Ok, it's a lot of tech words, here's the breakdown:

  • Ruby - Lovely scripting language that makes it easy to write clear concise code
  • Sinatra - Framework for creating web applications in Ruby, very simple to use
  • Unicorn - Quick and reliable HTTP server for Ruby
  • NGINX - (n-gin-x) HTTP server and reverse proxy, ultra quick for static files

Why? You could be drinking beer at home?

Using Unicorn and NGINX together we get the best of both for hosting our site, Unicorn handles the requests to the Ruby app and NGINX handles the static public files (Images/CSS/JS). GitHub posted a blog why they switched to Unicorn and the benefits.

Fine! Lets get this over with then!

Steps in this sample done in AWS EC2 Ubuntu 11.10 image:

  1. Install NGINX
  2. Start NGINX and test - "/etc/init.d/nginx start" but location of nginx depends on distro
  3. Install Ruby - "sudo apt-get install ruby1.9.1-dev" (actually installs 1.9.2), need dev version for gems
  4. Install Ruby gems
    1. Install make - "sudo apt-get install make" (may already be installed)
    2. Install gcc - "sudo apt-get install gcc" (may already be installed)
    3. Install gems - "sudo gem install unicorn sinatra"
  5. Check unicorn is working "unicorn -version" (if not check Ruby gems installed and are in path)
  6. TODO make simple sinatra app
  7. Test site
  8. TODO make config.ru
  9. TODO make unicorn.conf
  10. TODO mkdir /var/run/unicorn with perms to write
  11. start unicorn
  12. Add new nginx conf
  13. restart nginx
  14. Test site!