HomebrewでPHP5.3.6をインストールする
Formulaとあわせて手順を公開されてる記事があったのでそちらを参考に。
Formulaを落としてきて所定のディレクトリに配置。
$ curl -O https://github.com/ampt/homebrew/raw/php/Library/Formula/php.rb
$ mv php.rb `brew --prefix`/Library/Formula
インストールオプションを確認したり。
$ brew options php
php
--with-mysql
Include MySQL support
--with-pgsql
Include PostgreSQL support
--with-mssql
Include MSSQL-DB support
--with-fpm
Enable building of the fpm SAPI executable
--with-apache
Build shared Apache 2.0 Handler module
--with-intl
Include intl extension
--with-readline
Include readline extension
今回はmysql,pgsql,apache,intlをチョイス。
brew install php --with-mysql --with-pgsql --with-apache --with-intl
intlはSymfony2で遊ぶのに必要。pgsqlつけたらPostgreSQL本体もインストールされた。
ビルドが終わるまで待つ…インストールおわり。
次はパスを通したりの作業。MacにはもともとPHPが入っていて(Xcodeと一緒に入るんだっけ?)そっちが優先されるので、切り替えていく。
まずはCLIのPHPを切り替える。zsh使ってるので~/.zshenvに追記。
echo 'export PATH='`brew --prefix php`'/bin:$PATH' >> ~/.zshenv
次はApacheのPHP。/etc/apache2/httpd.confを編集。
#LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/Cellar/php/5.3.6/libexec/apache2/libphp5.so
$ sudo apachectl restart
これで終わり。