【问题标题】:file_put_contents() failed to open stream: Permission denied on CentOSfile_put_contents() 无法打开流:CentOS 上的权限被拒绝
【发布时间】:2022-03-01 13:46:13
【问题描述】:

我正在 CentOS 上部署一个 Laravel 应用程序。我遵循以下步骤:

  1. 克隆了我的仓库
  2. 已安装作曲家
  3. 设置配置

现在我在打开网站时收到以下错误消息:

file_put_contents(/var/www/portal/storage/framework/sessions/IDElrNpsn0hu9hjiXAzZRUTHyzm2fqvPHSLy0ZVN): failed to open stream: Permission denied

在 ubuntu 上,我使用以下命令解决了这个问题:

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

现在在 CentOS 上,以上 2 个命令不起作用,我收到 ErrorException。 谁能告诉我应该在 CentOS 7 中运行哪个命令来解决这个错误? 谢谢

【问题讨论】:

    标签: linux laravel centos


    【解决方案1】:

    问题已解决。 centOS的解决方案是使用apache而不是www-data。

    sudo chown -R $USER:apache storage
    sudo chown -R $USER:apache bootstrap/cache
    

    【讨论】:

      【解决方案2】:

      这对我来说是唯一的解决方案!! 3 天后,没有什么可做的,chmod chown ......这是 ffffff 服务器!

      semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/bagisto/bootstrap/cache(/.)?' semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/bagisto/storage(/.)?' restorecon -Rv '/var/www/bagisto'

      在这里查看更多! https://laracasts.com/discuss/channels/general-discussion/file-put-contents-2

      【讨论】:

      • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2011-06-22
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      • 2018-04-25
      • 2022-09-22
      • 2016-09-21
      相关资源
      最近更新 更多