用history模式构建的项目需要借助后台技术,这里选用的是nginx反向代理来部署项目。具体做法如下:
1、创建后台服务器 对象
upstream mixVueServer{ server baidu.com;#这里是自己服务器域名 }
2、创建访问端口和反向代理规则
server { listen 8082; server_name localhost; location / { root E:/mix_vue/dist;#定位到项目的目录 #index index.html index.htm; try_files $uri $uri/ /index.html;#根据官网这规则配置 } location ~ \.php${ proxy_pass http://mixVueServer;#根据后端语言做反向代理处理跨域问题 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
以上就是nginx中怎么部署访问vue-cli搭建的项目的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号