MAMPでPHPをコマンドラインから使うときのお作法

開発ツール
MAMPではじめるMac OS Xサーバサイドプログラミング

PHPをコマンドラインから実行するとなぜかphp.iniが読み込めてない風のwarningが

~~~
Warning: strftime() [function.strftime]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Tokyo’ for ‘JST/9.0/no DST’
~~~

??となってましたが使うにはお作法があるんですね

MAMPのPHPに実行権限をつけます

~~~
chmod u+x /Applications/MAMP/bin/php/php5.3.6/bin/php
~~~

PATHを通します

~~~
$ vim ~/.bashrc_local
export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH
~~~
※Macのみbashrcに書かなきゃいけないものはbashrc_localにまとめています

.bashrcを読み込み直す

~~~
$ souse ~/.bashrc_local
~~~

これでwarningが出なくなったので無事にMAMP上のPHPが呼ばれるようになりました

参考サイト:MAMPでPHP CLIを使うための覚え書き | イツカツクッテ

コメント

タイトルとURLをコピーしました