# CoinOX 部署文档(仅 Ubuntu) 仓库: 安装路径:`/opt/coinox` 进程名:`coinox`(PM2) 默认端口:`5010` 默认模式:**模拟盘**(`SIM_DEFAULT_MODE=sim`) 本项目**仅支持 Ubuntu 22.04 / 24.04 + root 一键部署**,不提供 Windows 部署步骤。 --- ## 一键交互式部署(推荐) 新服务器无需先 clone,root 执行: ```bash curl -fsSL https://git.bz121.com/dekun/CoinOX/raw/branch/main/deploy/manage.sh | bash ``` 已安装机器: ```bash bash /opt/coinox/deploy/manage.sh ``` ### 菜单 | 选项 | 功能 | |------|------| | **1) 一键部署** | 检测环境 + 系统依赖 + Node/PM2 + venv + `.env` + 启动 PM2 | | **2) 一键卸载** | 备份 `.env` → 停 PM2 → 移走目录 | | **3) 更新** | 快速更新 / 依赖更新 | | **4) 仅检测** | 识别 OS / Python / Node / PM2 / 项目状态(不安装) | | **0) 退出** | | ### 部署完成后 - 访问:`http://<服务器IP>:5010` - 默认入口:`/hedge-plan`(对冲)、`/options`(期权) - 登录:`admin` / `.env` 中 `APP_PASSWORD`(首次多为 `admin123`) - **默认模拟盘**:本地钱包撮合,不打真实私有下单 切实盘前请在 env / 系统设置中配置 `OKX_API_*`,并将交易模式切为 `live`,同时确认 `LIVE_TRADING_ENABLED`。 --- ## 脚本结构 ``` deploy/ ├── manage.sh # 入口(自举 + 交互菜单) ├── lib/ │ ├── common.sh │ ├── install.sh │ ├── uninstall.sh │ ├── update.sh │ └── doctor.sh ├── setup_env.sh └── pull_and_restart.sh ``` 详见 [deploy/README.md](./deploy/README.md)。 --- ## 分步安装(可选) ```bash cd /opt git clone -b main https://git.bz121.com/dekun/CoinOX.git coinox cd /opt/coinox bash deploy/setup_env.sh --install-system-deps pm2 start ecosystem.config.cjs pm2 save && pm2 startup ``` --- ## 常用运维 ```bash pm2 status pm2 logs coinox --lines 80 bash /opt/coinox/deploy/pull_and_restart.sh bash /opt/coinox/deploy/manage.sh # 选 3 更新 ``` --- ## 安全提醒 - 不要把 `.env`、API Key 提交到 Git - 公网务必改掉默认密码,并关闭 `APP_AUTH_DISABLED` - 模拟盘与实盘建议使用不同服务器或至少不同子账户 API