9
votes

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.

3

3 Answers

13
votes

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

7
votes

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

Exception trace:
 () at /data1/vhosts/website.com/vendor/psy/psysh/src/Psy/Configuration.php:459
 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
 mkdir() at /data1/vhosts/website.com/vendor/psy/psysh/src/Psy/Configuration.php:459
 Psy\Configuration->getHistoryFile() at /data1/vhosts/website.com/vendor/psy/psysh/src/Psy/Configuration.php:598

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.

5
votes

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