CakePHP 2.0 on MacOSX 10.7(Lion) とりあえず動くまでの設定

1.homebrewからSQLを入れる

Installation - GitHub
https://github.com/mxcl/homebrew/wiki/installation
以下実行前に要件をクリアしておく。

An Intel CPU 1
OS X 10.5 or higher
Xcode with X11 2
Java Developer Update 3

XcodeはMacAppStoreから無料で落として入れる。
結構時間かかる。

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

入れ終わったら、

$ brew install mysql

PostgreSQLなら

$ brew install postgresql

2.パスの検索順を変える

/usr/local/binのパス検索順が一番下になってるので、一番上にする。
.bash_profileで$PATHを書き換えても良いけど、根本的に/usr/local/binが一番下なのは微妙だなーと思うので、/etc/paths を書き換え。

3.Apache php5_moduleの読み込み

/etc/apache2/httpd.conf
以下、コメントアウト外す

LoadModule php5_module libexec/apache2/libphp5.so

4.Apache Virtual Hostの設定

2つの理由から、virtual hostの設定をする。

・当該CakePHPアプリのhttpdログを分離できる
mod_rewriteの設定にRewriteBaseをいちいち書かなくて良くなる

/etc/apache2/others/httpd-vhosts.conf

NameVirtualHost *:80

# For http://localhost in the OS X default location

ServerName localhost
DocumentRoot /Library/WebServer/Documents


# Set up permissions for VirtualHosts in ~/Sites

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

# VirtualHosts settings

ServerName cakephp.local
DocumentRoot "/Users/fifnel/Sites/cakephp/"
DirectoryIndex index.html index.php
CustomLog "/Users/fifnel/Sites/cakephp/logs/cakephp.local-access_log" combined
ErrorLog "/Users/fifnel/Sites/cakephp/logs/cakephp.local-error_log"

/etc/hosts

127.0.0.1 localhost cakephp.local

書き換えたらシステム環境設定の共有で、「Web共有」をOffにしてからOnにする(つまり再起動させる)