Debian 使用 root 部署 Zashboard
目标:在 Debian 上将静态站点目录 /opt/dist 通过 static-web-server 以 root 用户运行,使用 9091 端口提供内网访问。
https://github.com/Zephyruso/zashboard/releases
1. 确认站点文件
1 2
| sudo ls -la /opt/dist sudo test -f /opt/dist/index.html && echo "index.html OK" || echo "index.html 缺失"
|
2. 安装 static-web-server
1 2 3 4
| sudo apt update sudo apt install -y curl curl --proto '=https' --tlsv1.2 -sSfL https://get.static-web-server.net | sudo sh /usr/local/bin/static-web-server --version
|
3. 创建 systemd 服务(root 用户)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| sudo tee /etc/systemd/system/zashboard.service >/dev/null <<'EOF' [Unit] Description=Zashboard (static-web-server) After=network.target
[Service] Type=simple User=root Group=root WorkingDirectory=/opt/dist ExecStart=/usr/local/bin/static-web-server --host 0.0.0.0 --port 9091 --root /opt/dist --page-fallback /opt/dist/index.html --log-level info Restart=always RestartSec=2
[Install] WantedBy=multi-user.target EOF
|
4. 启动并设置开机自启
1 2 3
| sudo systemctl daemon-reload sudo systemctl enable --now zashboard sudo systemctl status zashboard --no-pager
|
5. 防火墙放行 9091(如启用 UFW)
1 2
| sudo ufw allow 9091/tcp sudo ufw status
|
6. 验证访问
本机检查:
1
| curl -I http://127.0.0.1:9091
|
浏览器访问:
1
| http://你的Debian内网IP:9091
|
7. 常用运维命令
1 2 3 4
| sudo systemctl start zashboard sudo systemctl restart zashboard sudo systemctl status zashboard --no-pager sudo journalctl -u zashboard -n 100 --no-pager
|
8. 更新站点内容
将新构建文件覆盖到 /opt/dist 后执行:
1
| sudo systemctl restart zashboard
|
9. 常见错误提示
如果你看到类似下面报错:
1
| invalid value '/opt/dist/index.html' for '--fd <FD>'
|
说明参数写错了,通常是把 -f 误当成 fallback 参数。请改回:
1
| --page-fallback /opt/dist/index.html
|
10. 删除 / 卸载步骤(完整)
如果你不再需要该服务,可按以下顺序清理:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| sudo systemctl stop zashboard sudo systemctl disable zashboard
sudo rm -f /etc/systemd/system/zashboard.service sudo systemctl daemon-reload sudo systemctl reset-failed
sudo rm -f /usr/local/bin/static-web-server
sudo rm -rf /opt/dist
sudo ufw status numbered
|
卸载后检查:
1 2 3
| systemctl status zashboard --no-pager || true which static-web-server || true ls -la /opt/dist || true
|