artisan tinker: mkdir() permission denied

六眼飞鱼酱① 提交于 2019-12-10 13:33:37

问题


Laravel Version 5.0.33

> php artisan tinker

  [ErrorException]            
  mkdir(): Permission denied  

This is on a production server, I was trying to test a command with tinker as the web user. This user owns every directory in the base path, so I'm not sure what directory is attempted to be created when I run artisan tinker.


回答1:


Using very verbose -vvv, I was able to get a stack trace.

Exception trace:
 () at /data1/vhosts/admin.stewartcoopercoon.com/vendor/psy/psysh/src/Psy/Configuration.php:459
 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
 mkdir() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/psy/psysh/src/Psy/Configuration.php:459
 Psy\Configuration->getHistoryFile() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/psy/psysh/src/Psy/Configuration.php:598
 Psy\Configuration->getReadline() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/psy/psysh/src/Psy/Shell.php:78
 Psy\Shell->__construct() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/TinkerCommand.php:51
 Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a
 call_user_func_array() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:526
 Illuminate\Container\Container->call() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
 Illuminate\Console\Command->execute() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
 Illuminate\Console\Command->run() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at /data1/vhosts/admin.stewartcoopercoon.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94
 Illuminate\Foundation\Console\Kernel->handle() at /data1/vhosts/admin.stewartcoopercoon.com/artisan:36

getHistoryFile() attempts to create a file in the user home directory, not the application directory. This user's home was set to /var/www/html but it didn't have execute permissions on that folder.




回答2:


Place .psysh.php in the root of a Laravel project with this content

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

More info https://github.com/laravel/tinker/issues/34#issuecomment-357550126




回答3:


This error occurs because you switch user (guessing using su) without "dash" option.

Replace su www-data with su - www-data and everything should works!

or

su - username

where username has the ssh login permission

The dash symbol before username is important

reference : here



来源:https://stackoverflow.com/questions/41601260/artisan-tinker-mkdir-permission-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!