- MAMPとは
- MAMPのダウンロード
- MAMPのインストール
- MAMPを開く
- php.initの設定(タイムゾーンの変更)
- MAMPのPHPにパスを通す
- php.init (設定ファイル)
- PHPのバージョン確認
- MySQLの操作
- MySQLにパスを通す
- PHPを実行してみる
php.initの設定(タイムゾーンの変更)
タイムゾーンを東京に変更
利用するphpのバージョンのディレクトリに移動する
$ cd /Applications/MAMP/bin/php/php*.*.*/conf/
date.timezoneを下記のように変更
date.timezone = "Asia/Tokyo"
MAMPのPHPにパスを通す
下記コマンドで.bash_profileがあるか確認
$ cd ~
$ ls -al
export PATH=/Applications/MAMP/bin/php/php7.3.7/bin:$PATH
設定を反映
$ source ~/.bash_profile
パスが通ったか確認
$ which php
このように表示されて入ればOK
※パスが通らない場合
下記を入力してOperation not permittedと出力された場合セキュリティ機能が効いている(自分もここで躓いた)
$ sudo mv /usr/bin/vim /usr/bin/old_vim
~/bin以下を変更する方法 [Operation not permittedの解決方法]
- Macを再起動する
- 立ち上げ時にcommand + Rを長押し
- 「日本語」を選択してください。
- 上のメニューバーからユーティリティ > ターミナルを起動
- ターミナルが起動したら下記コードを入力
$ csrutil status
- 下記コードで/bin以下を変更できるようにする
$ csrutil disable
- 変更した設定にするために下記コードを入力して再起動
$ reboot
php.init (設定ファイル)
PHPの設定を変更する場合、利用しているPHPのバージョンのphp.iniを編集すればOK
/Applications/MAMP/bin/php/php7.3.7/conf/php.ini
MySQLの操作
MAMPを起動して、下記に移動
$ cd /Applications/MAMP/Library/bin/
mysqlコマンドの実行
./mysql -u root -p
※パスワードはスタートページのMySQL部分を参照
パスワードを入力するとこのように表示される
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.26 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>