Laravel遷移數(shù)據(jù) could not be opened in append mode: failed to open stream: Permission denied錯(cuò)誤問(wèn)題的解決
在進(jìn)行Laravel項(xiàng)目的遷移過(guò)程中,在新的平臺(tái)因?yàn)闄?quán)限等因素導(dǎo)致出現(xiàn)如下錯(cuò)誤信息:
UnexpectedValueException
The stream or file "/www/wwwroot/m.shopglobalweb.com/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

這個(gè)是屬于常見(jiàn)的權(quán)限問(wèn)題,服務(wù)器的 storage 和 bootstrap/cache 目錄沒(méi)有寫(xiě)入權(quán)限,Laravel 無(wú)法生成日志、緩存文件。
錯(cuò)誤核心:/www/wwwroot/www.xxxxxx.com/storage/logs/laravel.log 權(quán)限不足,無(wú)法寫(xiě)入。
進(jìn)入項(xiàng)目根目錄后執(zhí)行這條命令:
# 1. 給 storage 目錄賦予讀寫(xiě)權(quán)限
chmod -R 755 storage
chmod -R 755 bootstrap/cache
# 2. 最關(guān)鍵:修改目錄所屬用戶(hù)(解決寶塔面板權(quán)限問(wèn)題)
chown -R www:www storage
chown -R www:www bootstrap/cache
如果還有錯(cuò)誤提示信息,我們需要執(zhí)行清空緩存命令:
php artisan cache:clear
php artisan config:clear



鄂公網(wǎng)安備 42090202000212號(hào)