Search code examples
phpopen-basedir

file_put_contents(): open_basedir restriction in effect. File(/tmp/XXX) is not within the allowed path(s): (/XXX) Ubuntu16.04


The problem is that type of error when I put my Laravel application on a server and Install a PDF plugin...

file_put_contents(): open_basedir restriction in effect. File(/tmp/XXXX) is not within the allowed path(s): (/home/admin/XXX)

So the problem here is that, there are too many wrong solutions on a internet, that said that we need to change .htaccess or httpd.conf (a file that doesn't exist LOL)

Or some another solutions that I found are placing something like that on apache configuration file:

<DirectoryMatch "/home/admin/web/XXX">
    php_admin_value open_basedir "/home/admin/web/XXXX"
</DirectoryMatch>

But it still doesn't work...

Obviously I tried to change open_basedir on php.ini file... and NOTHING!!

So what is the right answer? (for me :P)


Solution

  • THE ANSWER

    I found an answer accidentally... And only because I have spended more than 10 hours to solve that, I'm writing that solution...

    The variable that we need to change on php.ini IS NOT open_basedir

    BUT: sys_temp_dir = "/home/admin/XXX"

    and we also can leave open_basedir as comment...

    SURPRISE!!! :D