/etc/nginx/nginx.conf添加这一段
server {
listen 8090;
server_name www.guanacossj.com;
index index.html;
root /home/MyBlog/myblogfront/dist;
location / {
try_files $uri $uri/ /index.html;
}
}
root表示vue项目build后生成的dist目录,里面有static和index.html两个文件
在vue工程下,我这里是myblogfront,执行
npm run build
访问ip:8090即可
本文介绍如何在/etc/nginx/nginx.conf中配置Nginx服务器,使其能够正确地监听8090端口并指向Vue项目构建后的dist目录。通过在myblogfront项目下执行npm run build命令,实现静态资源的部署,使用户可以通过特定IP和端口访问到构建好的Vue应用。
2289

被折叠的 条评论
为什么被折叠?



