First you need php-cgi, i used brew with Formula below:
$ curl -O https://gist.github.com/raw/1131062/7ae1709453a8a19ce9c030bf41d544dd08d96d85/php.rb
$ mv php.rb `brew --prefix`/Library/Formula
$ brew install php --with-mysql
Second, install this ruby gems: