0%

mac下Nginx的安装

mac下Nginx的安装

首先看一下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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#执行命令
brew info nginx
#下面来解释一下下面的意思
--------------------------------------------------------
#最新已经到了1.19.6版本
nginx: stable 1.19.6 (bottled), HEAD

HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server

https://nginx.org/
#已经安装过了 安装的位置

/usr/local/Cellar/nginx/1.19.4 (25 files, 2.2MB) *
# 以及安装的时间

Poured from bottle on 2020-11-13 at 11:31:37
# 从哪个网站下载的

From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb

License: BSD-2-Clause
# 依赖

==> **Dependencies**
# openssl是可以没有的 pcre必须要有

Required: **openssl@1.1** **✘**, **pcre** **✔**

==> **Options**

--HEAD

​ Install HEAD version

==> **Caveats**
# Docroot网站根目录位置

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加载servers下的所有文件
nginx will load all files in /usr/local/etc/nginx/servers/.



To have launchd start nginx now and restart at login:

brew services start nginx

Or, if you don't want/need a background service you can just run:

nginx

==> **Analytics**

install: 35,316 (30 days), 124,077 (90 days), 453,743 (365 days)

install-on-request: 35,265 (30 days), 123,459 (90 days), 445,150 (365 days)

build-error: 0 (30 days)

既然说需要依赖pcre组件,那么pcre是干什么的呢

PCRE库支持正则表达式。如果我们在配置文件nginx.conf中使用了正则表达式,那么在编译Nginx时就必须把PCRE库编译进Nginx,因为Nginx的HTTP模块需要靠它来解析正则表达式。

进行安装nginx

1
brew install nginx

启动和停止nginx

这里提供两种方式来启动和停止nginx

一种是不作为一个后台服务来启动

1
2
3
4
#启动
nginx
# 停止
nginx -s stop

一种是作为后台服务来启动(开机自启动)

1
2
3
brew services start nginx

brew services stop nginx