Appearance
1. 准备部署环境
假设你已经安装好了以下软件:
- Nginx:作为反向代理服务器
- VitePress:已成功构建博客
该博客环境信息
a. VitePress 版本
- VitePress 版本: 1.6.3
b. Node.js 版本
- Node.js 版本: v18.18.2
- https://nodejs.org/download/release/v18.18.2/
3. npm 版本
- npm 版本: 9.8.1
d. 项目依赖
- 依赖列表:
- vitepress@1.6.3
- vue-pdf@4.3.0
2. 构建项目
在你的 博客
项目根目录下运行以下命令进行构建:
shell
cd /viteblog
npx vitepress build docs
这会在 docs/.vitepress/dist
目录下生成最终的构建文件。
3. 将构建文件复制到服务器目录
将构建生成的文件复制到部署目录。你已经执行了以下命令:
shell
cp -a docs/.vitepress/dist/. /主页目录/
这样,构建文件就已经成功复制到了 /app/code/linuxpath/
目录下。
4. 配置 Nginx 服务器
确保你的 Nginx 配置正确地指向博客文件所在的目录(即 /app/code/linuxpath/
)。例如:
shell
server {
listen 80;
server_name your-domain.com;
root index主页;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
5. 重新加载 Nginx 配置
完成 Nginx 配置后,重新加载 Nginx 使其生效:
shell
systemctl reload nginx
6. 访问博客
在浏览器中访问你的博客网站,确保它能够正常显示。可以通过你设置的域名或者直接使用服务器的 IP 地址访问:
shell
http://your-domain.com
7. 持续更新
当你对博客内容进行更改时,只需重新执行构建命令并复制更新后的构建文件到服务器:
shell
cd /viteblog
npx vitepress build docs
cp -a docs/.vitepress/dist/. /你的nginxroot目录/
systemctl reload nginx