Laravel权限Ubuntu VPS - Dig.Ocean - 运行但无法创建目录错误,或者如果没有更改权限,则为独白无法打开 fs 500 er



请帮帮我。我现在很痛苦,因为我反复尝试修复这个在myusername staff(user/group(设置上本地运行良好的伟大项目。在laravel中,我对所需的用户/组有点困惑,因为git是拉入代码的,我试图直接对其进行SFTP,但它仍然声称它是root。

我的根看起来像一个正常的laravel项目,运行得很愉快,但当我在我的CMS中打开一张照片时,我花了一些时间来节省时间,并帮助重复laravel项目CMS和组件的冗余,我可以在路线中构建和添加组件,但现在我想投入生产,因为我使用这个VPS,所以我遇到了问题。(Laravel版本是最新或半新版本(和php-4.3

/存储和/bootstrap目录由root所有,然后更改为www数据,除存储之外的所有目录都归myuser所有(让我们称之为myuser,nginx的www数据、ubuntu的我很不幸在完全设置液滴之前克隆了git存储库。任何能帮我拧下这个东西的东西都非常感谢。

SymfonyComponentHttpFoundationFileFile::getTargetFile
vendor/symfony/http-foundation/File/File.php:109

SymfonyComponentHttpFoundationFileExceptionFileException
Unable to create the "projectname/adminpanel/assets/img/profile/" directory.
SymfonyComponentHttpFoundationFileFile::getTargetFile
vendor/symfony/http-foundation/File/File.php:109

throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
}

@chmod($target, 0666 & ~umask());

return $target;
}

/**
* @return self
*/
protected function getTargetFile($directory, $name = null)
{
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
throw new FileException(sprintf('Unable to create the "%s" directory.', $directory));
}
} elseif (!is_writable($directory)) {
throw new FileException(sprintf('Unable to write in the "%s" directory.', $directory));
}

$target = rtrim($directory, '/\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));

return new self($target, false);
}

/**
* Returns locale independent base name of the given path.
*

现在我明白了和php手工存储:链接在用户向我抛出时运行

UnexpectedValueException  : The stream or file "/var/www/personal/storage/logs/laravel-2021-03-31.log" could not be opened: failed to open stream: Permission denied
at /var/www/personal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111
107|             restore_error_handler();
108|             if (!is_resource($this->stream)) {
109|                 $this->stream = null;
110| 
> 111|                 throw new UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
112|             }
113|         }
114| 
115|         if ($this->useLocking) {
Exception trace:
1   MonologHandlerStreamHandler::write()
/var/www/personal/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php:121
2   MonologHandlerRotatingFileHandler::write()
/var/www/personal/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:42
Please use the argument -v to see more details.

我最初处理的一个错误。我现在已经完全转了一圈,我得到了这个和500个错误,但至少我可以使用这个应用程序,它看起来很好,但有些事情完全错了——简单或复杂——也许如果有人能帮助解决这个新错误,我们就能识别出真正的问题,这可能与我的想法无关,据我所知,我只需要在站点启用更改和ubuntu设置更改后重新启动nginx,(也许/bootstrap和/storage-dir将所有权更改为www数据,然后重新启动,然后在没有500个错误的情况下运行,这是一个单一的日志错误,因为我一直在使用它和数据库来添加内容,我只是无法添加img内容,这个过程已经根据各自的位置创建了一个相关的目录和文件,在这种情况下,它位于配置文件设置中的adminpanel一侧,所以错误自然会出现很长一段时间,即../../adminpanel/../profile/**在上传一个128x128像素的头像到个人资料/目录中,我认为名字也是一样的(。我想我已经把它包含在问题中了,但现在我回来了,担心Unable to open file stream下面的新错误。哪些信息对再次进行故障诊断最有用。

默认情况下,public磁盘使用local驱动程序并将其文件存储在storage/app/public中。所以,我假设这就是你的图像存储的地方。

为了使这些文件可以从web访问,您应该创建一个从public/storagestorage/app/public的符号链接,只需运行

php artisan storage:link

最新更新