服務(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。