Skip to content

Commit 2478e94

Browse files
committed
doc: update docs/nginx.md
1 parent 508383a commit 2478e94

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

docs/nginx.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@ NGINX 备忘清单
1010
<!--rehype:wrap-class=row-span-2-->
1111

1212
```bash
13-
sudo systemctl status nginx # nginx当前状态
14-
sudo systemctl reload nginx # 重新加载 nginx
13+
sudo systemctl reload nginx # 重新加载 nginx
1514
sudo systemctl restart nginx # 重启nginx
16-
17-
sudo nginx -t # 检查语法
1815
nginx # 启动
1916
nginx -s reload # 重启
2017
nginx -s stop # 关闭进程
2118
nginx -s quit # 平滑关闭nginx
19+
```
20+
21+
状态
22+
23+
```bash
24+
sudo systemctl status nginx # nginx当前状态
2225
nginx -V # 查看nginx的安装状态,
2326
```
2427

25-
### Docker 安装
26-
<!--rehype:wrap-class=col-span-2-->
28+
检查语法
2729

2830
```bash
29-
docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
31+
sudo nginx -t # 检查语法
3032
```
3133

3234
### 简单代理
33-
<!--rehype:wrap-class=col-span-2-->
3435

3536
```nginx
3637
location / {
@@ -40,6 +41,38 @@ location / {
4041
}
4142
```
4243

44+
### 简单代理
45+
<!--rehype:wrap-class=row-span-2-->
46+
47+
Ubuntu/Debian
48+
49+
```shell
50+
$ sudo apt update && sudo apt install -y nginx
51+
```
52+
<!--rehype:className=wrap-text-->
53+
54+
RHEL/CentOS
55+
56+
```shell
57+
$ sudo yum install -y epel-release nginx && sudo systemctl enable --now nginx
58+
```
59+
<!--rehype:className=wrap-text-->
60+
61+
Docker 安装
62+
63+
```bash
64+
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
65+
```
66+
<!--rehype:className=wrap-text-->
67+
68+
### 配置路径
69+
70+
- `/etc/nginx/nginx.conf` _(main config)_
71+
- `/etc/nginx/conf.d/*.conf` _(drop‑ins)_
72+
- `/etc/nginx/sites-available/` + `sites-enabled/` _(Debian style)_
73+
- `/var/www/html` _(default docroot)_
74+
- `logs`: `/var/log/nginx/access.log`, `/var/log/nginx/error.log`
75+
4376
### 全局变量
4477
<!--rehype:wrap-class=col-span-2 row-span-4-->
4578

@@ -322,13 +355,13 @@ server {
322355
### 重定向(301永久)
323356
<!--rehype:wrap-class=row-span-2-->
324357

325-
将 <www.example.com> 重定向到 example.com
358+
将 <www.demo.com> 重定向到 demo.com
326359

327360
```nginx
328361
server {
329362
listen 80;
330-
server_name www.example.com;
331-
return 301 http://example.com$request_uri;
363+
server_name www.demo.com;
364+
return 301 http://demo.com$request_uri;
332365
}
333366
```
334367

@@ -337,8 +370,8 @@ server {
337370
```nginx
338371
server {
339372
listen 80;
340-
server_name example.com;
341-
return 301 https://example.com$request_uri;
373+
server_name demo.com;
374+
return 301 https://demo.com$request_uri;
342375
}
343376
```
344377

0 commit comments

Comments
 (0)