Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webdesign's avatar

file_put_contents() failed to open stream: Permission denied

hi guys i have a problem with laravel coding that i ran my project on cpanel and i encountered with an err as below .... i checked all permissions and i set all of my folder like storage and vendor to 777 permission on cpanel but unfortunately it didn't work and i googled it a lot ... I would be appreciated if you guide me

file_put_contents(/Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy): failed to open stream: Permission denied

in Filesystem.php (line 122)
at HandleExceptions->handleError(2, 'file_put_contents(/Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy): failed to open stream: Permission denied', '/home/webgraph/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', 122, array('path' => '/Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy', 'contents' => 'a:3:{s:6:"_token";s:40:"95GMZ8vTLxeX4QlFh7gKXrD23xp8HtSGvBxn20i4";s:9:"_previous";a:1:{s:3:"url";s:19:"http://webgraph.net";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', 'lock' => true))
at file_put_contents('/Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy', 'a:3:{s:6:"_token";s:40:"95GMZ8vTLxeX4QlFh7gKXrD23xp8HtSGvBxn20i4";s:9:"_previous";a:1:{s:3:"url";s:19:"http://webgraph.net";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', 2)
in Filesystem.php (line 122)
at Filesystem->put('/Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy', 'a:3:{s:6:"_token";s:40:"95GMZ8vTLxeX4QlFh7gKXrD23xp8HtSGvBxn20i4";s:9:"_previous";a:1:{s:3:"url";s:19:"http://webgraph.net";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', true)
in FileSessionHandler.php (line 83)
at FileSessionHandler->write('Ik8QAmCPtQ3uAwA8CrWuXj5er6l4wkmonsFTirKy', 'a:3:{s:6:"_token";s:40:"95GMZ8vTLxeX4QlFh7gKXrD23xp8HtSGvBxn20i4";s:9:"_previous";a:1:{s:3:"url";s:19:"http://webgraph.net";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}')
in Store.php (line 129)
at Store->save()
in StartSession.php (line 88)
at StartSession->terminate(object(Request), object(Response))
in Kernel.php (line 218)
at Kernel->terminateMiddleware(object(Request), object(Response))
in Kernel.php (line 189)
at Kernel->terminate(object(Request), object(Response))
in index.php (line 58)

http://i68.tinypic.com/maw4kz.jpg

0 likes
5 replies
ejdelmonico's avatar

Well the error message is pretty obvious, webserver user does not have permission to write files to DB. Examine the DB directory's permissions and owner. It should be 775. I haven't used cpanel in many years but i am sure you can find an options area if you can not adjust the permissions through SSH. Apache would look something like this depending on the owner/group:

sudo chown -R www-data:www-data /var/www

Also, make sure .htaccess file is correct. Try not to use 777 unless you are letting the user write to disk. 775 gives the user like apache and the group like apache rwx and the user r-x.

1 like
Cyberlord7's avatar

@ejdelmonico I followed your instruction and after running the command. I got Operation Not permitted. I'm using Kali distribution.

Snapey's avatar

@Cyberlord7 start your own question as it seems to have nothing to do with this one

1 like
webdesign's avatar

i made a new project the same version and after that at first move all of my controllers into new project then move all of my routes .... and this way works for me ....

Please or to participate in this conversation.