インストール
nginxのインストール
brew install nginx
※以下のメッセージを探す。ドキュメントルート(ファイルを置く場所)と設定ファイルの場所。
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080
phpのインストール
brew install php72
設定変更
設定変更
/usr/local/etc/nginx/nginx.conf
変更前
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
変更後
location ~ \.php$ {
root /usr/local/var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/var/www$fastcgi_script_name;
include fastcgi_params;
}
起動
起動
nginxの起動
brew services start nginx
phpの起動
brew services start php@7.2
動作確認
以下のURLにアクセスする
http://127.0.0.1:8080/
停止
nginxの停止
nginx -s stop
phpの停止
brew services stop php@7.2
参考
新しいmacにbrewを使ってnginxをインストールする
https://qiita.com/amemolee/items/56332100f182088687cf
CentOS + nginx + PHP環境でのnginxの設定めも
https://qiita.com/alegriaghost/items/57f99539a3554b4fbd80