日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

vue项目nginx部署子目录_vue 多项目部署---二级目录

發布時間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue项目nginx部署子目录_vue 多项目部署---二级目录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

新項目:同一域名下部署多個vue項目,

根目錄vue項目不需要按下面的方式進行打包部署

https://www.bitedit.com/

下面三個項目以二級目錄部署

https://www.bitedit.com/hmange
https://www.bitedit.com/api
https://www.bitedit.com/restful

以上鏈接不可用,作為示例,不要點擊。此方法適用于多vue項目,二級目錄部署

server {listen       80;server_name  www.bytedit.com;access_log  /var/log/nginx/bytedit.access.log;error_log   /var/log/nginx/bytedit.error.log;location ^~/ {alias /usr/local/nginx/html/front/;try_files $uri $uri/ /index.html;index index.html;}location ^~/hmanage {alias /usr/local/nginx/html/hmanage/;try_files $uri $uri/ /hmanage/index.html;index index.html;}location ^~/restful {alias /usr/local/nginx/html/restful/;try_files $uri $uri/ /restful/index.html;index index.html;}location ^~/api {alias /usr/local/nginx/html/api/;try_files $uri $uri/ /api/index.html;index index.html;}location /profile/image {proxy_set_header   Host             $host;proxy_set_header   X-Real-IP        $remote_addr;proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;proxy_pass http://127.0.0.1:8081/profile/image;}
}

前端在打包靜態文件的時候需要進行以下修改:

1、在vue.config.js 配置文件中,publicPath 和 outputDir 都改為 '/子目錄名/'。

2、入口文件 index.html 的head 標簽內加入

新增 <meta base="/子目錄名/">

vim public/index.html
新增 <meta base="/hmanage/"> 

3、vue-router 路由文件的配置,填寫二級目錄

新增 base: '/子目錄名/',

vim src/router/index.js
新增 base:'/hmanage/',

4、nginx 配置以及前端資源根目錄

    location ^~/hmanage {alias /usr/local/nginx/html/hmanage/;try_files $uri $uri/ /hmanage/index.html;index index.html;}

此方法適用于,多項目二級目錄部署,親測可用。

總結

以上是生活随笔為你收集整理的vue项目nginx部署子目录_vue 多项目部署---二级目录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。