在使用寶塔面板的服務(wù)器中修改open_basedir配置

服務(wù)器配置

阿里云學(xué)生主機(jī),Centos 7.2 64位,安裝了寶塔面板5.8.7,nginx1.12+php5.6+mysql5.5

遇到的問題

做了一個(gè)下載網(wǎng)站,使用阿里云CDN進(jìn)行下載加速。
自己的服務(wù)器上有兩個(gè)站點(diǎn),主站A和CDN回源站點(diǎn)B
主站A在服務(wù)器上的web根目錄為/www/wwwroot/A/
回源站點(diǎn)B的web根目錄為/www/wwwroot/B/

主站A使用php5開發(fā),當(dāng)有文件上傳時(shí),經(jīng)過安全驗(yàn)證的文件要移動(dòng)到站點(diǎn)B的data目錄中。
使用php中的函數(shù)move_uploaded_file()移動(dòng)上傳的文件到B/data/目錄中時(shí)報(bào)錯(cuò),信息如下:

move_uploaded_file(): open_basedir restriction in effect. 
File(/www/wwwroot/B/data/xxxxxxxx.txt) is not within the allowed path(s): 
(/www/wwwroot/A/:/tmp/:/proc/)

解決方法

/www/wwwroot/B/data/添加到站點(diǎn)A的open_basedir設(shè)置中即可。
無奈不知道open_basedir在哪里設(shè)置的

執(zhí)行grep -r "open_basedir" /etc/ 搜索無果
又執(zhí)行grep -r "open_basedir" /www/

查找到的部分內(nèi)容如下:

/www/wwwroot/A/.user.ini:open_basedir=/www/wwwroot/A/:/tmp/:/proc/
/www/wwwroot/B/.user.ini:open_basedir=/www/wwwroot/B/:/tmp/:/proc/

原來配置文件是隱藏文件.user.ini
打開A的.user.ini
改成 user.ini:open_basedir=/www/wwwroot/A/:/tmp/:/proc/:/www/wwwroot/B/data/
保存,重啟nginx。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容