Skip to content

Instantly share code, notes, and snippets.

@slumos
Created December 7, 2010 01:49
Show Gist options
  • Save slumos/731344 to your computer and use it in GitHub Desktop.
Save slumos/731344 to your computer and use it in GitHub Desktop.

Rolling with Homebrew (rather than MacPorts)

First, we have to install Homebrew. Once it's installed, we can do pretty much everything else via Homebrew. By default Homebrew will install to /usr/local. It's possible to choose a different directory but everything I've read so far says it's a PITA. I'm sticking with the default.

ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"

Getting your development environment running requires a few servers. You could get by with as little as Postgres and Memcached but it'll be better if you have Nginx and RabbitMQ as well. Eventually you'll probably want Redis and Artie as well.

TODO: instructions for Redis and Artie

Postgres

brew install postgresql
initdb /usr/local/var/postgres
cp /usr/local/Cellar/postgresql/8.4.4/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

Memcached

brew install memcached
cp /usr/local/Cellar/memcached/1.4.5/com.danga.memcached.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/com.danga.memcached.plist

Running tests requires a second instance of Memcached.

cp ~/Library/LaunchAgents/com.danga.memcached.plist \
   ~/Library/LaunchAgents/com.danga.memcached_11212.plist

Edit ~/Library/LaunchAgents/com.danga.memcached_11212.plist changing:

<string>com.danga.memcached_11212</string>

and

<array>
  <string>/usr/local/bin/memcached</string>
  <string>-U</string>
  <string>0</string>
  <string>-p</string>
  <string>11212</string>
  <string>-m</string>
  <string>16</string>
  <string>-l</string>
  <string>127.0.0.1</string>
</array>

then run

launchctl load -w ~/Library/LaunchAgents/com.danga.memcached_11212.plist

Nginx

% brew install nginx

Replace /usr/local/etc/nginx/nginx.conf with the sample below. Be sure to change PATH_TO_YOUR_WORKFEED_GIT_REPOSITORY.

Create /Library/LaunchAgents/org.nginx.server.plist using ...

sudo launchctl load -w /Library/LaunchAgents/org.nginx.server.plist

Git

brew install git

Ruby Enterprise Edition

brew install ruby-enterprise-edition

Ruby Gems

Make sure your PATH is set up to prefer HomeBrew's gem otherwise things will go very badly for you. Do not use Apple's Ruby: Goats + Dicks + Sylphis.

gem install taf2-curb --source=http://gems.github.com --no-rdoc --no-ri
gem install rack --version="1.0.1" --no-rdoc --no-ri
gem install json --version="1.2.1" --no-rdoc --no-ri
gem install     \
    sinatra     \
    v8          \
    hpricot     \
    nokogiri    \
    longurl     \
    tweetstream \
    memcached   \ 
    yajl-ruby   \
    tzinfo      \
    feedzirra   \
    system_timer\
    --no-rdoc --no-ri

vcprompt

This is a handy way to get your shell prompt to display git info.

brew install python
brew install pip
pip install mercurial
brew install vcprompt

Then stick "$(vcprompt)" somewhere in your shell prompt.

user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
### from nginx to unicorn
upstream www_yammer_dev {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
upstream www_yammer_dev_script_server {
server www.yammer.dev:3000;
}
### from browser to nginx
server {
listen 80;
server_name www.yammer.dev asset0.yammer.dev asset1.yammer.dev asset2.yammer.dev asset3.yammer.dev;
### rails public assets
root PATH_TO_YOUR_WORKFEED_GIT_REPOSITORY/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://www_yammer_dev_script_server;
break;
}
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /500.html {
root PATH_TO_YOUR_WORKFEED_GIT_REPOSITORY/public;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nginx.server</string>
<key>Program</key>
<string>/usr/local/sbin/nginx</string>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/sbin:/usr/bin:/bin:/usr/local/bin</string>
</dict>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment