前端程序员将vue项目打包之后,将dist文件发送给我,记录部署宝塔过程。

上传目录

将dist目录上传至TP5后台项目文件夹中,与public同级
项目目录结构:
image.png
注:dist目录名已被我修改

配置nginx

  1. server {
  2. listen 80;
  3. server_name h5.gasp.ydunicorn.store;
  4. root C:/wwwroot/gasp.ydunicorn.store/gasp_vue;
  5. location / {
  6. index index.html index.htm index.php;
  7. try_files $uri $uri/ @router; # 配置使用路由
  8. }
  9. error_page 500 502 503 504 /50x.html;
  10. location = /50x.html {
  11. root html;
  12. }
  13. # 路由配置信息
  14. location @router {
  15. rewrite ^.*$ /index.html last;
  16. }
  17. # 代理服务端接口
  18. location /face {
  19. proxy_pass http://gasp.ydunicorn.store/h5_api/; #将真正的请求代理到API 服务地址
  20. }
  21. }

注:location /face face为vue代码中的接口路由设置中自己定义的,正常为/api