阿里云部署本博客

小于 1 分钟

准备工作

服务器: 阿里云 Alibaba Cloud Linux 3.2104 LTS 64 位

服务器包: nginx zip unzip

nginx 配置

  1. 查看配置文件
nginx -t

# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful
  1. 修改配置文件
vim /etc/nginx/nginx.conf
# user nginx;
user root;  # 设置用户 访问首页出现403说明权限不够
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

server {
  listen       80;
  listen       [::]:80;
  server_name  47.115.215.103;  # Ip / 域名
  charset      utf-8;
  root         /root/home/www/vuepress/dist;  # 首页路径
}

 









 

  1. 重启 nginx
nginx -s reload

部署流程

1. 本地 build 代码

2. 压缩 dist 文件夹

3. 将压缩后的 dist.zip 传输到服务器

# mac ftp 传输
put <本地 dist.zip 路径> <服务器路径>

# window Xshell

4. 服务器解压 dist.zip 到指定目录

# 进入到 dist.zip 所在目录
cd <dist.zip所在目录>

# 解压
unzip -o dist.zip