Skip to content

Commit 299eef5

Browse files
committed
feat: 命名规范
文件夹及文件名重命名
1 parent fb3e742 commit 299eef5

File tree

86 files changed

+873
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+873
-343
lines changed

docs/.vitepress/config.mjs

Lines changed: 464 additions & 342 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

docs/backend/nginx笔记.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Nginx笔记
2+
## 常用命令
3+
```bash
4+
nginx -t
5+
nginx -s reload
6+
nginx -s stop
7+
```
8+
## 介绍
9+
Nginx 是一款高性能的 Web 服务器和反向代理服务器,广泛用于处理 HTTP、HTTPS 等请求。以下是常用的 Nginx 命令及其说明:
10+
11+
---
12+
13+
### **Nginx 常用命令**
14+
这些命令通常在终端中输入,假设 Nginx 已安装且配置正确。
15+
16+
1. **启动 Nginx**
17+
```bash
18+
nginx
19+
```
20+
- 直接启动 Nginx 服务,使用默认配置文件(通常是 `/etc/nginx/nginx.conf` 或安装路径下的 `nginx.conf`)。
21+
- 如果需要指定配置文件:
22+
```bash
23+
nginx -c /path/to/nginx.conf
24+
```
25+
26+
2. **停止 Nginx**
27+
```bash
28+
nginx -s stop
29+
```
30+
- 立即停止 Nginx 服务,强制关闭所有连接。
31+
- 更优雅的停止方式(等待现有连接处理完成):
32+
```bash
33+
nginx -s quit
34+
```
35+
36+
3. **重新加载配置文件**
37+
```bash
38+
nginx -s reload
39+
```
40+
- 在不中断服务的情况下重新加载配置文件,适用于修改配置后更新。
41+
42+
4. **测试配置文件语法**
43+
```bash
44+
nginx -t
45+
```
46+
- 检查 Nginx 配置文件语法是否正确,默认检查 `/etc/nginx/nginx.conf`
47+
- 指定配置文件:
48+
```bash
49+
nginx -t -c /path/to/nginx.conf
50+
```
51+
52+
5. **查看 Nginx 版本**
53+
```bash
54+
nginx -v
55+
```
56+
- 显示 Nginx 的版本号。
57+
- 如果需要更详细信息(如编译参数):
58+
```bash
59+
nginx -V
60+
```
61+
62+
6. **重启 Nginx**
63+
- Nginx 没有直接的重启命令,通常组合使用停止和启动:
64+
```bash
65+
nginx -s stop && nginx
66+
```
67+
- 或者通过系统服务管理工具(取决于操作系统):
68+
```bash
69+
systemctl restart nginx # 对于使用 systemd 的系统
70+
service nginx restart # 对于使用 init.d 的系统
71+
```
72+
73+
7. **查看 Nginx 运行状态**
74+
- 检查进程:
75+
```bash
76+
ps -ef | grep nginx
77+
```
78+
- 或使用服务状态:
79+
```bash
80+
systemctl status nginx # 对于 systemd 系统
81+
```
82+
83+
8. **发送信号**
84+
- Nginx 支持通过 `-s` 参数发送信号,常见信号包括:
85+
- `stop`:快速停止。
86+
- `quit`:优雅停止。
87+
- `reload`:重新加载配置。
88+
- `reopen`:重新打开日志文件(用于日志切割):
89+
```bash
90+
nginx -s reopen
91+
```
92+
93+
---
94+
95+
### **Nginx 简介**
96+
- **什么是 Nginx?**
97+
Nginx(发音为 "engine-x")是一个开源的高性能 Web 服务器、反向代理服务器和负载均衡器,由 Igor Sysoev 于 2004 年开发。它以异步事件驱动架构著称,能够处理大量并发连接,同时保持低内存和 CPU 占用。
98+
99+
- **主要功能**
100+
- **Web 服务器**:提供静态文件服务,支持 HTTP/HTTPS。
101+
- **反向代理**:将客户端请求转发到后端服务器。
102+
- **负载均衡**:支持多种算法(如轮询、IP 哈希)分发流量。
103+
- **邮件代理**:支持 IMAP/POP3/SMTP 协议。
104+
- **缓存**:提供静态内容和代理内容的缓存功能。
105+
106+
- **优点**
107+
- 高并发:单实例可处理数万并发连接。
108+
- 低资源占用:相比传统服务器(如 Apache),内存和 CPU 使用效率更高。
109+
- 配置简单:配置文件结构清晰,支持模块化扩展。
110+
111+
- **典型使用场景**
112+
- 托管静态网站。
113+
- 为动态应用(如 PHP、Python、Node.js)提供反向代理。
114+
- 实现负载均衡和高可用性。
115+
- 处理 HTTPS 流量并提供 SSL/TLS 证书支持。
116+
117+
---
118+
119+
### **配置文件基础**
120+
Nginx 的核心配置文件通常位于 `/etc/nginx/nginx.conf`,主要包含以下部分:
121+
- `http {}`:HTTP 服务的全局配置。
122+
- `server {}`:定义虚拟主机(网站)。
123+
- `location {}`:定义特定路径的处理规则。
124+
125+
示例:
126+
```nginx
127+
http {
128+
server {
129+
listen 80;
130+
server_name example.com;
131+
location / {
132+
root /var/www/html;
133+
index index.html;
134+
}
135+
}
136+
}
137+
```
138+
139+
---
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)