Mac安装Nginx

安装

1
brew install nginx

结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
==> Installing nginx
==> Pouring nginx--1.21.6.monterey.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www

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

nginx will load all files in /usr/local/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:
/usr/local/opt/nginx/bin/nginx -g daemon off;
==> Summary
🍺 /usr/local/Cellar/nginx/1.21.6: 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: /usr/local/var/www

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

nginx will load all files in /usr/local/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:
/usr/local/opt/nginx/bin/nginx -g daemon off;
➜ ~

配置信息

文档根目录

1
/usr/local/var/www

默认配置文件:

1
/usr/local/etc/nginx/nginx.conf

默认端口设置成了 8080​ ,这样是为了不用 sudo 来启动

nginx 的安装路径:

1
/usr/local/Cellar/nginx/1.21.6**

启动 Nginx

1
brew services start nginx

重启 Nginx

1
brew services restart nginx

非后台启动

1
/usr/local/opt/nginx/bin/nginx -g daemon off

停止 Nginx

1
brew services stop nginx
作者

Terwer

发布于

2022-04-29

更新于

2023-08-27

许可协议

评论