I upload the file to my cent OS server a few days ago, it was working fine, but from today I am getting the error.
The stream or file "/var/www/html/hasibtest/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
Where My log file is with 777 permission I am also trying with 0755, 0644
can anyone tell me how I can resolve this issue?
first try this to take ownership of the directory recursively
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
Then use the following to set proper directory access
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Never Set dircetory permissions to 777 (Unless you know what you are doing)
Note that you must change both. the ownership and permission, as well as the folders in these two folders. This should affect to all children
sudo chown -R apache storage
sudo chown -R apache bootstrap/cache
and
chmod -R 775 storage
chmod -R 775 bootstrap/cache
you can check owner
ls -lr
That command will show you who has ownership.
check current user: <?php echo exec('whoami'); ?>
i'm using lampp on ubuntu, so the result is daemon
then run several command, thank @Shobi
sudo chown -R daemon:www-data storage
sudo chown -R daemon:www-data bootstrap/cache
now it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With