事实上,我是laravel的新手,我正在尝试创建我的第一个项目。出于某种原因,我一直得到这个错误(我甚至还没有开始编码)

Error in exception handler: The stream or file "/var/www/laravel/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/laravel/bootstrap/compiled.php:8423

我读到这与权限有关,但chmod -R 775存储根本没有帮助。


当前回答

试试这个

cd /var/www/html setenforce 0 服务HTTPD重启

其他回答

它也可能是SELinux。(Centos RedHat)

确定终端上SElinux的状态:

$ sestatus

如果status为enabled,写命令禁用SElinux

$ setenforce Permissive

或者你可以执行这个命令

$ sudo setenforce 0

尝试了这里建议的任何方法都没有成功。

对我有用的是:

sudo chmod -R ugo+rw storage
sudo chmod -R ugo+rw storage/logs

这个解决方案是针对laravel 5.5的

你必须改变几个文件夹的权限: chmod -R -777 storage/logs . sh chmod -R -777 storage/framework 对于上面的文件夹,775或765不适合我的项目

chmod -R 775 bootstrap/cache 

此外,项目文件夹的所有权应该如下(当前用户):(web服务器用户)

添加到composer.json

"scripts": {
    "post-install-cmd": [
          "chgrp -R www-data storage bootstrap/cache",
          "chmod -R ug+rwx storage bootstrap/cache"
     ]
}

安装composer后

只需在项目根目录-中运行以下命令

sudo chmod -R 775 storage
sudo chown -R $USER:www-data storage