macOS(Monterey)でnginxをインストール

mcaOSを最新のMontereyにアップデートし、nginxをインストールしてみたので備忘として。

```
$ brew install nginx
```
インストール先は
/opt/homebrew/
になるらしい...
一応実行結果
```
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
bartib                           ddh                              hut                              sqls                             vcluster
==> Updated Formulae
Updated 396 formulae.

==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2022-04-26
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:c05a44feba2a630de2e1cefba90d3aa3f74e4d57146c0117858f648c419abeae
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c05a44feba2a630de2e1cefba90d3aa3f74e4d57146c0117858f648c419abeae?se=2022-04-27
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/manifests/1.21.6_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nginx/blobs/sha256:737ab2f1858bc8f3378f19da55e98d79f4014452e7ac37ab713b13c828ec95cc
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:737ab2f1858bc8f3378f19da55e98d79f4014452e7ac37ab713b13c828ec95cc?se=2022-04-27
######################################################################## 100.0%
==> Installing dependencies for nginx: ca-certificates
==> Installing nginx dependency: ca-certificates
==> Pouring ca-certificates--2022-04-26.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /opt/homebrew/Cellar/ca-certificates/2022-04-26: 3 files, 215.6KB
==> Installing nginx
==> Pouring nginx--1.21.6_1.arm64_monterey.bottle.tar.gz
==> Caveats
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon off;
==> Summary
🍺  /opt/homebrew/Cellar/nginx/1.21.6_1: 26 files, 2.2MB
==> Running `brew cleanup nginx`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> nginx
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon off;
```

- nginxのバージョンを確認
```
$ nginx -v
nginx version: nginx/1.21.6
```

- confファイル
```
/opt/homebrew/etc/nginx/nginx.conf
```

- nginx起動
```
$ sudo nginx
```
http://localhost:8080/

![スクリーンショット 2022-04-27 15.50.23.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2644537/861f1fa5-b9cf-3996-9dee-e9c0fbd07361.png)

- nginx停止
```
$ sudo nginx -s stop
```
※停止のコマンドを打ってもlocalhostを叩くとnginxのページが出るのは何故だ？

参考
https://phiary.me/mac-nginx-install/
https://qiita.com/you-me/items/5548424ebe360e5f9dda