# 快速开始 ## 前提 - 主机已安装 nginx 1.26(含 `nginx-module-njs`),由 systemd 托管 - 文档目录:`/app/markdown`,对外路径:`/md/` ## 首次安装(一次性) ```bash yum -y install nginx nginx-module-njs mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak cp /app/mdview/nginx.conf /etc/nginx/nginx.conf systemctl enable --now nginx ``` ## 启动 / 停止 ```bash systemctl start nginx systemctl stop nginx systemctl restart nginx systemctl reload nginx # 平滑重载 ``` ## 访问 - 首页:`http://10.2.24.13/md/` - 单篇:`http://10.2.24.13/md/快速开始.md` - 根路径 `http://10.2.24.13/` 会 301 跳到 `/md/` ## 验证 ```bash curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/md/ # 200 curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1/ # 301 curl -s http://127.0.0.1/md/快速开始.md | head -3 ``` ## 常用操作 | 操作 | 命令 | | --- | --- | | 看日志 | `journalctl -fu nginx` / `tail -f /var/log/nginx/error.log` | | 配置自检 | `nginx -t` | | 重启 | `systemctl restart nginx` | | 停止 | `systemctl stop nginx` | | 改配置后生效 | `systemctl reload nginx`(或 `nginx -s reload`) | ## 常见问题 > **改了 md 文件没变化?** > 浏览器缓存,强制刷新(Ctrl/Cmd + Shift + R)。 > **404?** > 路径区分大小写;非 `.md` 的附件(图片等)走 `/` + 原路径,同样从 `/md/` 下取。