1. MAMP のインストール
ここ から DL 。今現在の最新バージョンは 2.1.1 。インストール時に Pro のトライアル版?は省く形にしました。その他、特になにもしなければ /Applications/ に MAMP がインストールされます。
2. MAMP の環境設定
MAMP を起動して 環境設定 を選択。それぞれのタブは以下のように設定しました。( ここらへんは人によって設定が違ってきますので注意 )
- 起動/停止: MAMPの起動時にサーバを起動 と MAMPの終了時にサーバを停止 にチェック
- ポート: Apache と MySQL の標準ポートに設定 をクリック
- PHP: バージョンを 5.4.4, Cache を APC
- Apache: Document Root は /Users/jamband/Dropbox/htdocs
あとは スタートページを開く をクリックして、正常に動作しているか確認します。
3. php.iniの設定
MAMP で 利用している PHP のバージョンが 5.4.4 なので
/Applications/MAMP/bin/php/php5.4.4/conf/ の php.ini を修正していくことになります。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# エラー表示 | |
display_errors = On | |
# タイムゾーン | |
date.timezone = "Asia/Tokyo" | |
# 文字コード | |
default_charset = "UTF-8" | |
mbstring.language = Japanese | |
mbstring.internal_encoding = UTF-8 | |
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII | |
# Xdebug | |
xdebug.remote_enable = On | |
xdebug.remote_handler = dbgp | |
xdebug.remote_mode = req | |
xdebug.remote_host = 127.0.0.1 | |
xdebug.remote_port = 9000 | |
xdebug.var_display_max_depth = 16 | |
xdebug.idekey = | |
xdebug.profiler_enable = On | |
xdebug.profiler_output_dir = "/Applications/MAMP/tmp/xdebug/" |
4. PHPUnit の導入
pear を使って PHPUnit を入れます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /Applications/MAMP/bin/php/php5.4.4/bin | |
pear upgrade-all | |
sudo pear config-set auto_discover 1 | |
pear install --force --alldeps pear.phpunit.de/PHPUnit | |
pear install phpunit/PHPUnit_Selenium | |
pear install phpunit/DbUnit | |
pear install phpunit/PHPUnit_Story |
5. MySQL の設定
設定といってもとりあえずは文字コードくらいです。
/Applications/MAMP/Library/support-files/my-large.cnf をコピーして /Applications/MAMP/conf/ に置いて my.cnf にリネームして、以下を追加。
my-small.cnf だと、トリガを作ろうとしたときか、使ったときかに Thread stack overrun: ... みたいなエラーが出たので my-large.cnf にしました。
/Applications/MAMP/Library/support-files/my-large.cnf をコピーして /Applications/MAMP/conf/ に置いて my.cnf にリネームして、以下を追加。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysqld] | |
skip-character-set-client-handshake | |
character-set-server=utf8 | |
[mysql] | |
default-character-set=utf8 |
まとめ
これで MAMP を使っていろいろプログラムがかけるような環境が整いました。本当は Homebrew を使って PHP の開発環境を整えたいんですが、まだまだよくわからないことが多いので、とりあえずはこんな感じで。
0 件のコメント:
コメントを投稿