vue部署到nginx 超简单

0.安装SecureCRT

https://www.vandyke.com/products/securecrt/

下载完成后 打开SecureCRT连接你的阿里云你的实例

1.安装nginx

yum install nginx

systemctl start nginx // 启动nginx

输入 公网ip 如果出现 welcome nginx 则成功

2.安装lrzsz

yum install nginx

3.编译vue项目(build)

4.压缩dist

tar -czf dist.tar.gz dist

5.SecureCRT里输入

cd /home
mkdir vue
cd vue
rz
选择 dist.tar.gz 上传

6.到上传好的目录里解压:

tar -xzvf dist.tar.gz

7.配置nginx

find / -name nginx
vim /etc/nginx/nginx.conf

nginx.conf

server {
    listen       80;
    server_name  localhost;
    root         /usr/share/nginx/html;
    
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    
    location / {
            root /home/vue/dist;
            # 如果你配置router mode:history
            try_files $uri $uri/ /index.html;
            index index.html;
    }
    
    error_page 404 /404.html;
        location = /40x.html {
    }
    
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
  1. 重启nginx
nginx -s reload
  1. 输入的公网ip到浏览器 成功

你可能感兴趣的:(vue部署到nginx 超简单)