Files
2026-06-23 22:52:48 +08:00

99 lines
1.9 KiB
Markdown

# 智币省 - 服务器部署提示词
## 部署命令
在服务器上执行以下命令部署智币省应用:
```bash
# 1. 安装 Node.js (如果未安装)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# 2. 安装 PM2
sudo npm install -g pm2
# 3. 创建项目目录
sudo mkdir -p /var/www/zhibisheng
cd /var/www/zhibisheng
# 4. 克隆代码(或手动上传)
git clone http://www.rhettcloud.top:17003/rhettclaw/zhibisheng.git .
# 5. 安装依赖
npm install
# 6. 配置环境变量(如需要)
# PORT=3000
# 7. 启动服务
pm2 start ecosystem.config.js --name zhibisheng
# 8. 设置开机自启
pm2 save
pm2 startup
# 9. 配置 Nginx 反向代理到 17009 端口
```
## Nginx 配置示例
```nginx
server {
listen 80;
server_name _;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
```
## PM2 配置文件 (ecosystem.config.js)
```javascript
module.exports = {
apps: [{
name: 'zhibisheng',
script: 'server.js',
cwd: '/var/www/zhibisheng',
instances: 1,
exec_mode: 'fork',
env: {
PORT: 3000,
NODE_ENV: 'production'
},
error_file: '/var/log/zhibisheng-error.log',
out_file: '/var/log/zhibisheng-out.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
autorestart: true,
max_memory_restart: '500M'
}]
};
```
## 验证部署
```bash
# 检查服务状态
pm2 status
# 查看日志
pm2 logs zhibisheng
# 测试 API
curl http://127.0.0.1:3000/api/today-deals
# 重启服务
pm2 restart zhibisheng
```
## 端口说明
- **应用端口**: 3000 (Node.js 直接监听)
- **对外端口**: 17009 (通过 Nginx 或防火墙映射)