原文地址:https://www.wjcms.net/archives/laravel報錯xxxlaravellogcouldnotbeopenedfailedtoopenstreampermissiondenied
laravel報錯:The stream or file "/xxx/laravel.log" could not be opened: failed to open stream: Permission denied
今天在搭建一個laravel項目時,突然報上述錯誤,從字面意思上來看是沒有權限,解決這個問題當然從權限考慮。
可以直接將文件夾權限設置為777,但是這樣非常不安全,所以千萬別這么做。
應該更改目錄所有者。因此,設置當前用戶,使你以所有者身份登錄,並以webserver用戶(www,apache……)作為組登錄,這里運行下面兩條命令:
sudo chgrp -R www storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
即可成功解決上述問題。