Laravel - "artisan tinker" -> mkdir(): 权限被拒绝

5

我已经搜索了几个小时,但是即使有类似的问题,我仍然找不到解决方案。

我正在尝试在具有用户 webmaster (是项目目录 demo 的所有者)的新laravel安装上运行 php artisan tinker ,但是我得到以下错误:

In Configuration.php line 352:
mkdir(): Permission denied

使用详细模式运行:

异常跟踪: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() 在 n/a:n/a mkdir() 在 /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Configuration.php:352 Psy\Configuration->getRuntimeDir() 在 /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Shell.php:185 Psy\Shell->getDefaultCommands() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:1211 Symfony\Component\Console\Application->init() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:435 Symfony\Component\Console\Application->add() 在 /media/usb/drive1/websites/demo/vendor/psy/psysh/src/Psy/Shell.php:134 Psy\Shell->add() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:421 Symfony\Component\Console\Application->addCommands() 在 /media/usb/drive1/websites/demo/vendor/laravel/tinker/src/Console/TinkerCommand.php:54 Laravel\Tinker\Console\TinkerCommand->handle() 在 n/a:n/a call_user_func_array() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Container/Container.php:549 Illuminate\Container\Container->call() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Command.php:183 Illuminate\Console\Command->execute() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Command/Command.php:252 Symfony\Component\Console\Command\Command->run() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Command.php:170 Illuminate\Console\Command->run() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:938 Symfony\Component\Console\Application->doRunCommand() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:240 Symfony\Component\Console\Application->doRun() 在 /media/usb/drive1/websites/demo/vendor/symfony/console/Application.php:148 Symfony\Component\Console\Application->run() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Console/Application.php:88 Illuminate\Console\Application->run() 在 /media/usb/drive1/websites/demo/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:121 Illuminate\Foundation\Console\Kernel->handle() 在 /media/usb/drive1/websites/demo/artisan:37

希望有人能给我一些提示。谢谢!

相关信息

  • 发行版: Raspbian GNU/Linux 8 (jessie)
  • Web服务器: Apache/2.4.25
  • Laravel版本: 5.5 (最新版本)
  • DocumentRoot: /var/www/websites -> /media/usb/drive1/websites/
  • Apache用户: www-data (在项目目录中具有权限)

类似报告的问题


3
DocumentRoot 应该是 Laravel 的 public/ 文件夹。你是否正确设置了它? - brombeer
没错,但我正在运行一个开发服务器,有多个项目要通过域名访问。无论如何,我不认为这与此问题有关。 - pixelmusik
你尝试过在 Configuration->getRuntimeDir() 中转储runtimeDir以查找权限被拒绝的位置吗? - sisve
@sisve 感谢您的评论!我该如何将一个变量转储到终端? - pixelmusik
1
dump($variable); - sisve
1个回答

11

距离我提出这个问题已经一年了。我简单地忽略了tinker的使用问题并继续前进。但是今天我终于找到了解决方案,认为分享出来可能是一个好主意。

共享服务器环境可能会导致此错误。从文件vendor/psy/psysh/src/Configuration.php的第352行转储变量$this->runtimeDir告诉我缺少在/run/user/1000/psysh中创建文件夹的权限,其中1000是uid。

解决方法是告诉psysh使用操作用户具有写访问权限的目录。这可以通过runtimeDir配置选项来完成。您需要做的就是在〜/ .config / psysh / config.php中创建配置文件,或者在Laravel项目根目录中本地创建.psysh.php。添加以下内容即可开始。

<?php
return [
    'runtimeDir' => './.psysh',
];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接