Vue项目部署到云服务器

打包

Vue项目执行打包命令,如npm run build
打包完成会在项目根目录下生成一个dist的目录,将该目录重命名后上传到服务器

修改nginx的配置文件

vim /.../conf/nginx.conf
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /home/projectXXX; # 项目dist目录
            try_files $uri $uri/ /index.html;  # 解决刷新报404的问题
            index  index.html index.htm;
        }

更改完重新加载配置文件

./nginx -s reload

原文地址:https://www.cnblogs.com/JeromeLong/p/15758850.html