【问题标题】:Public path error in laravel 5.6 [duplicate]laravel 5.6中的公共路径错误[重复]
【发布时间】:2018-12-01 09:20:07
【问题描述】:

我已经安装了新的 laravel 5.6,但是当我打开 laravel public 时……它给了我如下错误

/var/lib/jenkins/workspace/ytl/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php

$this->createDir();
        $this->errorMessage = null;
        set_error_handler(array($this, 'customErrorHandler'));
        $this->stream = fopen($this->url, 'a');
        if ($this->filePermission !== null) {
            @chmod($this->url, $this->filePermission);
        }
        restore_error_handler();
        if (!is_resource($this->stream)) {
            $this->stream = null;
            throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
        }
    }

    if ($this->useLocking) {
        // ignoring errors here, there's not much we can do about them
        flock($this->stream, LOCK_EX);
    }

    $this->streamWrite($this->stream, $record);

    if ($this->useLocking) {
        flock($this->stream, LOCK_UN);
    }
}

"流或文件 “/var/lib/jenkins/workspace/ytl/storage/logs/laravel.log”不能 已打开:无法打开流:权限被拒绝”

【问题讨论】:

  • 可能会发生另一个错误,但网络用户无权写入您的日志。很清楚的错误信息,你检查过你的网络用户对存储/日志的权限吗?
  • 是的@Devon 另一个视图有同样的错误...我给两个文件夹 777 权限然后网站打开

标签: laravel laravel-5.6


【解决方案1】:

您需要在项目的根目录下运行chmod 775 -R storage。这将允许运行 PHP 的用户写入该目录。您可能还需要对 bootstrap 目录执行此操作。

【讨论】:

  • 对于整个存储目录来说,这些都是相当开放的权限。我不建议在共享服务器上这样做......如果网络用户不是所有者或不属于某个组,它也仍然不可写。
  • 同意,但是,某些基础设施提供商(例如 Google App Engine 和 AWS Beanstalk)需要它。否则它的问题是改变整个目录的所有者
  • 它工作了,但是它对项目没有好处吗? @尼克
  • 我有自己的服务器@Devon
  • 那么 775 应该没问题,因为您不必担心其他人对这些目录中的文件具有执行/读取权限。
猜你喜欢
  • 2013-06-05
  • 2017-01-20
  • 2016-09-02
  • 2018-07-29
  • 2018-09-26
  • 2021-12-31
  • 2013-05-08
  • 2016-07-27
  • 2022-01-21
相关资源
最近更新 更多