Skip to content

Instantly share code, notes, and snippets.

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
@kewinwang
kewinwang / puppet_master_seed_prod_8140.conf
Created January 9, 2012 16:12 — forked from jeffmccune/puppet_master_seed_prod_8140.conf
Puppet Master Front End Load Balancer configuration
## Apache Load Balancer Front End ##
# Puppet Apache::Config[010_frontend_puppet_prod.conf]
# This file managed by Puppet from a template.
# source: puppet_frontend_XXXX.conf
# All CA requests should be directed to specific workers
<Proxy balancer://puppet_prod_ca>
# Only one member
BalancerMember http://puppetca.puppetlabs.vm:18140
@kewinwang
kewinwang / gist:1476411
Created December 14, 2011 12:36 — forked from samqiu/railscasts.rb
download railscast video
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
@kewinwang
kewinwang / UpgradeCentOSRuby.sh
Created October 21, 2011 07:21 — forked from jimjeffers/Ruby_1.9.2-p290_on_Ubuntu_10.4
Upgrade CentOS ruby to 1.8.7 -p299 and install passenger.
# Install ruby 1.8.7 -p299
sudo mkdir /usr/local/src
cd /usr/local/src
sudo curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz
sudo tar xzvf ruby-1.8.7-p299.tar.gz
cd ruby-1.8.7-p299
sudo ./configure --enable-shared --enable-pthread
sudo make
sudo make install
cd ext/zlib
@kewinwang
kewinwang / full.plugin.list.txt
Created September 29, 2011 14:48 — forked from briandoll/full.plugin.list.txt
Full Plugin List Deployed in applications monitored by New Relic, September 2011
Full Plugin List Deployed in Rails applications monitored by New Relic, September 2011
Count Plugin Name
-------------------
2040 rpm
1534 newrelic_rpm
1268 acts_as_list
1186 paperclip
1130 will_paginate
1068 exception_notification
@kewinwang
kewinwang / full.gem.list.txt
Created September 29, 2011 14:47
Full Gem List Deployed in ruby applications monitored by New Relic, September 2011
Full Gem List Deployed in ruby applications monitored by New Relic, September 2011
Count Gem Name
----------------
7570 rack
7444 rake
7425 rails
7424 activesupport
7421 bundler
7412 actionpack
#!/bin/sh
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes
# http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/
# Work with 64bit kernel mode
set -e
PREFIX=/usr/local
# Passenger users: amend your Apache global configuration with the following directive
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
@kewinwang
kewinwang / .irbrc
Created May 18, 2011 09:55
custom configuration ~/.irbrc file
require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
IRB.conf[:IRB_RC] = proc do |conf|