Files
code/nginx切换完成报告.md
2026-01-28 15:29:13 +08:00

270 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Nginx切换完成报告
**切换时间:** 2025年1月28日
**服务器IP** 101.43.95.130
---
## 切换操作总结
### ✅ 已完成的操作
1.**停止宝塔nginx**
- 已停止所有宝塔nginx进程
- 宝塔nginx不再运行
2.**启动系统nginx**
- 系统nginx服务已启动
- 已启用开机自启动
3.**更新系统nginx配置**
- 添加域名:`www.ruilaizipj.com`
- SSL证书配置已正确
- ThinkPHP路由规则已配置
4.**验证服务状态**
- 80端口正常监听
- 443端口正常监听
- HTTP访问正常
- HTTPS访问正常
---
## 当前运行状态
### Nginx服务状态
| 项目 | 状态 | 说明 |
|------|------|------|
| **系统nginx** | ✅ 正在运行 | 主进程:`/usr/sbin/nginx -c /etc/nginx/nginx.conf` |
| **宝塔nginx** | ❌ 已停止 | 不再运行 |
| **80端口** | ✅ 正常监听 | HTTP访问 |
| **443端口** | ✅ 正常监听 | HTTPS访问 |
### Nginx进程信息
**系统nginx进程**
- 主进程:`/usr/sbin/nginx -c /etc/nginx/nginx.conf`
- Worker进程正常运行
- 配置文件:`/etc/nginx/conf.d/default.conf`
---
## 配置文件位置
### 系统nginx配置
**主配置文件:**
```
/etc/nginx/nginx.conf
```
**网站配置文件:**
```
/etc/nginx/conf.d/default.conf
```
### SSL证书文件
**证书文件:**
```
/www/server/panel/vhost/cert/101.43.95.130/fullchain.pem
```
**私钥文件:**
```
/www/server/panel/vhost/cert/101.43.95.130/privkey.pem
```
---
## 当前nginx配置
### 完整配置内容
```nginx
server {
listen 80 default_server;
listen 443 ssl http2 default_server;
server_name localhost 101.43.95.130 www.ruilaizipj.com;
ssl_certificate /www/server/panel/vhost/cert/101.43.95.130/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/101.43.95.130/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
location / {
root /www/wwwroot/code/public;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ [^/]\.php(/|$)
{
root /www/wwwroot/code/public;
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-56.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
```
---
## 访问测试结果
### HTTP访问
**测试地址:** `http://101.43.95.130`
**测试结果:**
```
HTTP/1.1 200 OK
Server: nginx/1.20.2
```
**状态:正常**
### HTTPS访问
**测试地址1** `https://101.43.95.130`
**测试结果:**
```
HTTP/1.1 200 OK
Server: nginx/1.20.2
```
**状态:正常**
**测试地址2** `https://www.ruilaizipj.com`
**测试结果:**
```
HTTP/1.1 200 OK
Server: nginx/1.20.2
```
**状态:正常**
### SSL证书验证
**证书信息:**
- 域名www.ruilaizipj.com
- 有效期2026-01-28 至 2026-04-27
**证书验证:正常**
---
## 服务管理命令
### 系统nginx管理
```bash
# 启动nginx
systemctl start nginx
# 停止nginx
systemctl stop nginx
# 重启nginx
systemctl restart nginx
# 重载配置(不中断服务)
systemctl reload nginx
# 或
nginx -s reload
# 检查配置
nginx -t
# 查看状态
systemctl status nginx
```
### 开机自启动
系统nginx已启用开机自启动
```bash
systemctl enable nginx
```
---
## 切换前后对比
| 项目 | 切换前 | 切换后 |
|------|--------|--------|
| **使用的nginx** | 宝塔nginx | 系统nginx |
| **配置文件** | `/www/server/nginx/conf/nginx.conf` | `/etc/nginx/nginx.conf` |
| **网站配置** | `/www/server/panel/vhost/nginx/101.43.95.130.conf` | `/etc/nginx/conf.d/default.conf` |
| **80端口** | ✅ 正常 | ✅ 正常 |
| **443端口** | ✅ 正常 | ✅ 正常 |
| **HTTP访问** | ✅ 正常 | ✅ 正常 |
| **HTTPS访问** | ✅ 正常 | ✅ 正常 |
---
## 注意事项
### 1. 配置文件位置
- **系统nginx配置** `/etc/nginx/conf.d/default.conf`
- **宝塔nginx配置** `/www/server/panel/vhost/nginx/101.43.95.130.conf`(已不使用)
### 2. 修改配置
如果需要修改网站配置,请编辑:
```
/etc/nginx/conf.d/default.conf
```
修改后执行:
```bash
nginx -t && nginx -s reload
```
### 3. SSL证书
SSL证书文件位置不变继续使用
- 证书:`/www/server/panel/vhost/cert/101.43.95.130/fullchain.pem`
- 私钥:`/www/server/panel/vhost/cert/101.43.95.130/privkey.pem`
---
## 验证清单
- ✅ 系统nginx正在运行
- ✅ 宝塔nginx已停止
- ✅ 80端口正常监听
- ✅ 443端口正常监听
- ✅ HTTP访问正常
- ✅ HTTPS访问正常
- ✅ SSL证书正确
- ✅ 域名访问正常
- ✅ 开机自启动已启用
---
## 总结
**切换成功!**
现在使用系统nginx提供服务宝塔nginx已停止。所有服务正常运行HTTP和HTTPS访问都正常。
**配置文件位置:** `/etc/nginx/conf.d/default.conf`
---
**切换完成时间:** 2025年1月28日
**服务器IP** 101.43.95.130