美文网首页
Linux的nginx环境的vue 部署

Linux的nginx环境的vue 部署

作者: 凌雲木 | 来源:发表于2019-04-12 15:24 被阅读0次

使用npm run build打包Vue项目(在此使用的是IVue-Admin框架),生成打包文件

打包生成的文件
使用FTP把打包文件上传到linux服务器
修改nginx配置文件
添加一个Server
#www.mysite1.com
    server {
        listen       80;
          #域名/主机名
        server_name  www.mysite1.com;
        location / {
            #linux服务器存放打包文件的路径
            root   /home/fcj/Desktop/dist/;
            index  index.html;
       }
}

查看nginx配置是否正确:
sudo nginx -t
重读配置文件
nginx -s reload

root@ubuntu:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@ubuntu:~# nginx -s reload
root@ubuntu:~# 

在浏览器输入网址 www.mysite1.com

image.png
由此:部署成功

刷新报错问题解决:

server {
        listen       8015;
        server_name  localhost;
        location / {
            root   /home/fcj/Desktop/dist/;
            try_files $uri $uri/ @router;
            index  index.html;
        }
        location @router {
            rewrite ^.*$ /index.html last;
        }
    }

相关文章

网友评论

      本文标题:Linux的nginx环境的vue 部署

      本文链接:https://www.haomeiwen.com/subject/akpcwqtx.html