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:
- Install NGINX
- Start NGINX and test – “/etc/init.d/nginx start” but location of nginx depends on distro
- Install Ruby – “sudo apt-get install ruby1.9.1-dev” (actually installs 1.9.2), need dev version for gems
- Install Ruby gems
- Install make – “sudo apt-get install make” (may already be installed)
- Install gcc – “sudo apt-get install gcc” (may already be installed)
- Install gems – “sudo gem install unicorn sinatra”
- Check unicorn is working “unicorn -version” (if not check Ruby gems installed and are in path)
- TODO make simple sinatra app
- Test site
- TODO make config.ru
- TODO make unicorn.conf
- TODO mkdir /var/run/unicorn with perms to write
- start unicorn
- Add new nginx conf
- restart nginx
- Test site!