使用npm run build
打包Vue项目(在此使用的是IVue-Admin框架),生成打包文件
![](https://img.haomeiwen.com/i4942211/a5d4041e2ccc890f.png)
使用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
![](https://img.haomeiwen.com/i4942211/7c01a26f4b44792f.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;
}
}
网友评论