安装 nginx
brew install nginx
安装完成控制台的打印信息
aaron@AarondeMacBook-Pro develop % brew install nginx
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/pcre2-10.39.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/nginx-1.21.6_1.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for nginx: pcre2
==> Installing nginx dependency: pcre2
==> Pouring pcre2-10.39.arm64_monterey.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pcre2/10.39: 230 files, 6.0MB
==> 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
brew services start nginx
重启
brew services restart nginx
关闭
brew services stop nginx
根据控制台输出的信息可知
配置文件的路径
/opt/homebrew/etc/nginx/nginx.conf
默认加载文件的路径
nginx will load all files in /opt/homebrew/etc/nginx/servers/.
加载文件的路径是在 nginx.conf 最后一行配置的
include servers/*;
设置只加载配置文件
include servers/*.conf;
查看安装目录,及配置文件目录
brew info nginx