百度雲虛擬主機BCH部署多個vue項目


注意:此文章使用百度雲虛擬主機BCH服務器web內核用Nginx,PHP版本7.0。

第一步:再php配置里把URL_MODEL 配置成2,重寫模式;

第二步:在網站的根目錄里面(webroot目錄下)新建一個bcloud_nginx_user.conf文件(bch是不允許修改基礎配置文件的,所以只能通過加載用戶自定義配置文件),寫入如下代碼:

location /hehe {
    if (!-e $request_filename) {
        rewrite .* /hehe/index.php last;
    }
}

以上代碼實現在‘hehe’目錄下指向不存在文件,則重定向至/hehe/index.php文件

第三步:在主機控制面板中找到站點啟停,點擊重載站點服務。(切記修改完規則之后一定要重新加載否則不能生效)

多個vue項目部署在此處依然生效

location /hehe {
    if (!-e $request_filename) {
        rewrite .* /hehe/index.php last;
    }
}
location /website_admin {
    if (!-e $request_filename) {
        rewrite .* /website_admin/index.html last;
    }
}
location /website {
    if (!-e $request_filename) {
        rewrite .* /website/index.html last;
    }
}

Nginx配置文件加載流程

系統啟動后將自動加載bcloud_nginx_gen.conf和bcloud_nginx_user.conf配置文件:

bcloud_nginx_gen.conf文件是由app.conf文件轉換的。

bcloud_nginx_user.conf為用戶自定義配置文件。用戶可在程序根目錄下,創建bcloud_nginx_user.conf文件,在文件里寫入自定義配置。BCH支持server級別以下的自定義配置。

當出現重復配置時,bcloud_nginx_user.conf優先級高於bcloud_nginx_gen.conf。

常見程序百度雲偽靜態規則

http://z.admin5.com/index.php?r=index/rewrite


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM