2026-06-05 23:37:37 +08:00
|
|
|
|
# 1Panel + Docker 一键部署
|
|
|
|
|
|
|
2026-06-06 07:08:42 +08:00
|
|
|
|
> 完整知识文档:[docs/project/nexus-1panel-operations-knowledge.md](../docs/project/nexus-1panel-operations-knowledge.md)
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
## 脚本速查(公共仓库 · 无需令牌)
|
|
|
|
|
|
|
|
|
|
|
|
| 脚本 | 用途 | 一条命令 |
|
|
|
|
|
|
|------|------|----------|
|
|
|
|
|
|
| `quick-install.sh` | 仅装 Nexus(1Panel 已就绪) | `curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" \| bash` |
|
|
|
|
|
|
| `install-1panel-docker.sh` | 重装服务器全链 | `curl -fsSL ".../install-1panel-docker.sh" \| bash` |
|
|
|
|
|
|
| `install-nexus-fresh.sh` | 全新空库安装 | `bash deploy/install-nexus-fresh.sh --skip-clone` |
|
|
|
|
|
|
| **`update.sh`** | **一键更新** | `curl -fsSL ".../update.sh" \| bash` |
|
|
|
|
|
|
| `nexus-1panel.sh` | 底层 install / upgrade | `bash deploy/nexus-1panel.sh upgrade` |
|
2026-06-06 06:19:19 +08:00
|
|
|
|
| `fix-1panel-mysql-grant.sh` | 修复 1045 nexus@Docker | `bash deploy/fix-1panel-mysql-grant.sh` |
|
2026-06-06 07:08:42 +08:00
|
|
|
|
| `test-1panel-redis.sh` | Redis 认证诊断 | `REDIS_PASS='...' bash deploy/test-1panel-redis.sh` |
|
2026-06-06 04:27:11 +08:00
|
|
|
|
| **`nx`** | **统一运维菜单** | `nx` |
|
|
|
|
|
|
|
|
|
|
|
|
档位:`--profile 1c4g` · `2c8g`(默认)· `4c16g`
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 重装服务器(1Panel + Docker + Nexus)
|
2026-06-05 23:44:38 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-06 02:00:24 +08:00
|
|
|
|
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/install-1panel-docker.sh" | bash
|
2026-06-05 23:44:38 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 00:11:43 +08:00
|
|
|
|
4 核 16G:
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-06 04:27:11 +08:00
|
|
|
|
curl -fsSL ".../install-1panel-docker.sh" | bash -s -- --profile 4c16g
|
2026-06-06 02:00:24 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
已装 1Panel,只装 Nexus:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-06 04:27:11 +08:00
|
|
|
|
curl -fsSL ".../install-1panel-docker.sh" | bash -s -- --skip-1panel
|
2026-06-06 02:00:24 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
## 仅 Nexus Docker
|
2026-06-06 02:00:24 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/quick-install.sh" | bash
|
2026-06-05 23:37:37 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
安装完成后:`https://api.synaglobal.vip/app/install.html`
|
2026-06-06 02:00:24 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
---
|
2026-06-06 02:00:24 +08:00
|
|
|
|
|
2026-06-06 04:16:15 +08:00
|
|
|
|
## 一键更新(日常)
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd /opt/nexus && bash deploy/update.sh
|
2026-06-06 04:27:11 +08:00
|
|
|
|
# 或
|
|
|
|
|
|
nx update
|
|
|
|
|
|
# 或菜单
|
|
|
|
|
|
nx # → [4] 一键更新
|
2026-06-06 04:16:15 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
| 选项 | 说明 |
|
|
|
|
|
|
|------|------|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
| `--check` | 仅查 Git,不重建 |
|
|
|
|
|
|
| `--no-cache` | 无缓存重建镜像(entrypoint 变更后必用) |
|
2026-06-06 04:16:15 +08:00
|
|
|
|
| `--no-backup` | 跳过 MySQL 备份 |
|
2026-06-06 04:27:11 +08:00
|
|
|
|
| `--prune` | 清理悬空镜像 |
|
2026-06-06 04:16:15 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
远程:
|
2026-06-06 04:16:15 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -fsSL "http://66.154.115.8:3000/admin/Nexus/raw/branch/main/deploy/update.sh" | bash
|
2026-06-06 04:27:11 +08:00
|
|
|
|
curl -fsSL ".../update.sh" | bash -s -- --no-cache
|
2026-06-06 04:16:15 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
---
|
|
|
|
|
|
|
2026-06-06 04:43:00 +08:00
|
|
|
|
## NX 全局命令
|
|
|
|
|
|
|
|
|
|
|
|
安装 / 升级 / 首次运行 `nx` 会自动注册到 `/usr/local/bin`:
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-06 04:43:00 +08:00
|
|
|
|
# 手动注册(任意目录可用 nx)
|
|
|
|
|
|
NEXUS_ROOT=/opt/nexus bash /opt/nexus/deploy/install-nx-cli.sh
|
|
|
|
|
|
|
|
|
|
|
|
nx # 统一运维菜单
|
2026-06-06 04:27:11 +08:00
|
|
|
|
nexus-update # 等同 update.sh
|
|
|
|
|
|
nexus-fresh # 等同 install-nexus-fresh.sh
|
|
|
|
|
|
nexus-install # 等同 quick-install.sh
|
2026-06-05 23:37:37 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
| 菜单 | 功能 |
|
|
|
|
|
|
|------|------|
|
|
|
|
|
|
| `[1]` | 安装向导(档位 / 迁机 / skip-clone) |
|
|
|
|
|
|
| `[2]` | 全新安装 → `/app/install.html` |
|
|
|
|
|
|
| `[4]` | **一键更新** |
|
|
|
|
|
|
| `[5]` | 重启 Nexus |
|
|
|
|
|
|
| `[6]` | 日志 |
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
---
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
## MySQL / Redis(1Panel 应用商店)
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
Docker 栈**仅含 Nexus 容器**。MySQL / Redis 在 **1Panel 应用商店**安装。
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
### 1Panel 官方互联方式(必读)
|
2026-06-06 04:27:11 +08:00
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
[1Panel 维护者说明](https://github.com/1Panel-dev/1Panel/issues/11676):应用商店应用使用 **bridge + `1panel-network`**;**容器之间用容器名通信**(Docker 内置 DNS),不要用 `localhost` / `127.0.0.1` / `host.docker.internal`。
|
2026-06-06 05:22:16 +08:00
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
| 场景 | 正确主机 |
|
|
|
|
|
|
|------|----------|
|
|
|
|
|
|
| Nexus → 1Panel MySQL | `1Panel-mysql-xxxx`(容器列表中的名称) |
|
|
|
|
|
|
| Nexus → 1Panel Redis | `1Panel-redis-xxxx` |
|
|
|
|
|
|
| OpenResty → 应用 | `127.0.0.1:端口`(OpenResty 为 host 网络) |
|
|
|
|
|
|
|
|
|
|
|
|
`nx update` / `nexus-1panel.sh` 会:
|
|
|
|
|
|
|
|
|
|
|
|
1. 将 Nexus 加入 **`1panel-network`**(`docker/docker-compose.1panel.yml`)
|
2026-06-06 05:39:52 +08:00
|
|
|
|
2. 自动探测 MySQL/Redis 容器名写入 `docker/.env.prod`(含 `NEXUS_REDIS_URL=redis://1Panel-redis-xxxx:6379/0`)
|
|
|
|
|
|
3. 安装向导步骤 3 **预填 MySQL/Redis 容器名**
|
2026-06-06 05:35:04 +08:00
|
|
|
|
|
|
|
|
|
|
### 安装步骤
|
|
|
|
|
|
|
|
|
|
|
|
1. **应用商店** → 安装 **MySQL**、**Redis**
|
2026-06-06 05:22:16 +08:00
|
|
|
|
2. **数据库** → 创建库 `nexus`、用户 `nexus`(仅授权 `nexus` 库),记下密码
|
2026-06-06 05:35:04 +08:00
|
|
|
|
3. `nx update` 后打开安装向导步骤 3(主机应已预填 `1Panel-mysql-…`)
|
2026-06-06 07:15:57 +08:00
|
|
|
|
4. 填写 MySQL 密码;Redis:**用户名通常留空** + 应用参数密码(自动尝试 `:pass@` / `default`)
|
2026-06-06 05:22:16 +08:00
|
|
|
|
|
2026-06-06 06:19:19 +08:00
|
|
|
|
### 常见错误 1045(Access denied for 'nexus'@'172.18.x.x')
|
|
|
|
|
|
|
|
|
|
|
|
TCP 已通,但 MySQL 用户多为 **`nexus@localhost`**,Docker 内 Nexus 从 **172.x** 连接会被拒绝。
|
|
|
|
|
|
|
|
|
|
|
|
在服务器执行(按提示输入 root 密码与 nexus 密码):
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd /opt/nexus && bash deploy/fix-1panel-mysql-grant.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
或一次性:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
MYSQL_ROOT_PASSWORD='1Panel里MySQL的root密码' \
|
|
|
|
|
|
NEXUS_DB_PASSWORD='向导里要填的nexus密码' \
|
|
|
|
|
|
bash /opt/nexus/deploy/fix-1panel-mysql-grant.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
然后安装向导步骤 3:**库名/用户 `nexus`**,主机为 `1Panel-mysql-xxxx`,密码与上面一致。
|
|
|
|
|
|
|
2026-06-06 05:39:52 +08:00
|
|
|
|
若仍报 `Can't connect to MySQL/Redis on 'host.docker.internal'`:说明 Nexus **未接入 1panel-network** 或未探测到容器名,在服务器执行:
|
2026-06-06 05:22:16 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-06 05:35:04 +08:00
|
|
|
|
cd /opt/nexus && bash deploy/detect-1panel-services.sh
|
|
|
|
|
|
nx update --no-cache
|
2026-06-06 05:22:16 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-06-06 05:35:04 +08:00
|
|
|
|
步骤 2 会 TCP 检测 MySQL/Redis;步骤 4 验证账号密码。
|
2026-06-06 04:27:11 +08:00
|
|
|
|
|
|
|
|
|
|
卸载旧 Compose 容器:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
bash deploy/uninstall-mysql-compose.sh
|
|
|
|
|
|
bash deploy/uninstall-redis-compose.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
---
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
## 1Panel 反代
|
2026-06-05 23:37:37 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
**禁止**脚本改 `/opt/1panel/apps/openresty/`。
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
1. 应用商店 → **OpenResty**
|
|
|
|
|
|
2. 网站 → 反代 `http://127.0.0.1:8600`
|
|
|
|
|
|
3. 参考:`deploy/1panel/openresty-nexus.conf.example`
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
---
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
## 密钥
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
新机自动生成 `NEXUS_SECRET_KEY` / `NEXUS_API_KEY` / `NEXUS_ENCRYPTION_KEY` → `docker/.env.prod`,备份 `/root/.nexus-install-secrets-*.env`。
|
2026-06-06 03:27:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
MySQL 密码在 1Panel 自建库时设定,向导步骤 3 填写。
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
|
|
|
|
|
| 场景 | 命令 |
|
|
|
|
|
|
|------|------|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
| 新机 | `curl \| quick-install.sh` |
|
|
|
|
|
|
| 迁机 | `nexus-1panel.sh install --from-env /path/to/.env` |
|
|
|
|
|
|
| 更新 | `update.sh` 或 `nx update` |
|
2026-06-06 00:25:57 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
**Git**:公开仓库 `clone` / `pull` / `curl | bash` 无需令牌。
|
2026-06-06 01:14:59 +08:00
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
---
|
2026-06-06 01:14:59 +08:00
|
|
|
|
|
2026-06-06 06:05:15 +08:00
|
|
|
|
## 安装向导验收(服务器执行)
|
|
|
|
|
|
|
|
|
|
|
|
在 **1Panel 终端**(root)一键检查网络、容器名预填、本地 `/health` 与 `/api/install/env-check`:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd /opt/nexus && bash deploy/verify-1panel-install-wizard.sh
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
通过后再浏览器打开 `https://你的域名/app/install.html`。常见修复:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd /opt/nexus && bash deploy/detect-1panel-services.sh
|
|
|
|
|
|
nx update --no-cache
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
外网 HTTPS 仍失败但脚本本地检查全绿 → 在 1Panel **网站**配置反代 `http://127.0.0.1:8600`(见 `deploy/1panel/openresty-nexus.conf.example`)。
|
|
|
|
|
|
|
2026-06-06 04:27:11 +08:00
|
|
|
|
## 安装向导热修复
|
2026-06-06 01:14:59 +08:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
cd /opt/nexus && git pull
|
2026-06-06 04:27:11 +08:00
|
|
|
|
bash deploy/update.sh --no-cache
|
|
|
|
|
|
# 或仅同步静态:
|
2026-06-06 01:14:59 +08:00
|
|
|
|
bash deploy/sync-install-wizard-to-container.sh
|
|
|
|
|
|
```
|