Mac安装Nginx
# Mac安装Nginx
# 安装
brew install nginx
1
结果如下:
==> 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
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
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
# 配置信息
文档根目录
/usr/local/var/www
1
默认配置文件:
/usr/local/etc/nginx/nginx.conf
1
默认端口设置成了 8080
,这样是为了不用sudo来启动
nginx的安装路径:
/usr/local/Cellar/nginx/1.21.6**
1
# 启动Nginx
brew services start nginx
1
# 重启Nginx
brew services restart nginx
1
# 非后台启动
/usr/local/opt/nginx/bin/nginx -g daemon off
1
# 停止Nginx
brew services stop nginx
1
编辑 (opens new window)
上次更新: 2023/09/19, 13:33:19