【问题标题】:Laravel The stream or file "storage/laravel.log" could not be opened in append mode: failed to open stream: Permission denied in RHEL8Laravel 无法以附加模式打开流或文件“storage/laravel.log”:无法打开流:RHEL8 中的权限被拒绝
【发布时间】:2021-02-09 12:56:15
【问题描述】:

我在这里需要帮助。我在我的 RHEL 8 服务器中安装了 Laravel

但是我收到了这个错误。我知道这个问题已经发布了很多次,但我试图遵循这个建议,但到目前为止我没有运气。我不知道为什么。

The stream or file "/var/www/html/vpa/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

我尝试使用此命令更改权限,但没有成功。

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache 
sudo chmod -R 755 storage
sudo chmod -R 755 bootstrap/cache

sudo setenforce 0 
sudo chcon -t httpd_sys_rw_content_t storage

php artisan config:clear
php artisan config:cache
composer dump-autoload

sudo systemctl restart httpd
sudo reboot 

我这边似乎没有任何效果。我不知道还能做什么。请帮帮我

【问题讨论】:

  • 我也面临这个问题。我在 Nginx 上运行我的应用程序。不管怎样,已经有一段时间了。你最终能自己解决吗?
  • 我刚刚通过运行setenforce 0 解决了我的问题。
  • @KelvinLow。我在 RHEL8 中找到了解决方案。您需要将 chmod 设置为 775 以用于文件夹存储和引导/缓存而不是 755。是的,您需要 'setenforce 0'
  • 很高兴知道。您介意回答自己的问题,以便其他人知道您的问题已得到解答吗?

标签: laravel rhel8


【解决方案1】:

在 ubuntu 上这一步解决了它

php artisan config:clear

php artisan cache:clear

sudo chmod -R 775 /var/www/your_folder

sudo chown -R www-data:www-data var/www/your_folder 

【讨论】:

    【解决方案2】:

    sudo chmod +w storage/logs/laravel.log

    永远不要使用 777

    那些是不负责任的权限

    【讨论】:

      【解决方案3】:

      我通过运行以下命令更改了我的存储权限。它适用于我:

      第 1 步:

      sudo chmod -R +rwX .

      第 2 步:

      sudo chown -R $(whoami) .

      【讨论】:

      • 您能补充一下您在哪里吗?您执行这些命令的路径是什么。
      • @Pathros 感谢您的询问。基本上,我在 Visual Studio 代码中从事 laravel 项目,但遇到了存储问题。然后我打开 Visual Studio 代码 *terminal 并执行这些命令,它对我有用。
      【解决方案4】:

      简单的读/写权限允许运行此命令

      chmod -R 777 /storage/laravel.log”
      

      【讨论】:

      • 从不推荐777755 要好得多。
      【解决方案5】:

      就我而言,除了确保所有权限都正确之外,我还必须禁用 SELinux。

      【讨论】:

        【解决方案6】:

        为我工作。

        sudo chown -R $USER:$USER /var/www
        sudo chmod -R 755 /var/www
        sudo chmod -R 777 storage/*
        sudo chmod -R 777 bootstrap/*
        

        【讨论】:

        • 从不推荐777755 要好得多。
        【解决方案7】:

        这对我有用

        sudo chown -R www-data:www-data ./storage
        find ./storage -type d -exec chmod 775 {} \;
        find ./storage -type f -exec chmod 664 {} \;
        sudo chown www-data:www-data ./bootstrap/cache -R
        find ./bootstrap/cache -type d -exec chmod 775 {} \;
        sudo chown -R www-data:www-data .env
        find .env -type d -exec chmod 775 {} \;
        

        【讨论】:

          猜你喜欢
          • 2021-10-03
          • 2018-07-08
          • 2021-10-03
          • 2018-05-06
          • 2018-10-03
          • 2021-06-26
          • 2020-06-16
          • 2019-02-10
          • 2022-07-07
          相关资源
          最近更新 更多