I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some reason I keep getting this error (I haven't even started coding yet)
Error in exception handler: The stream or file "/var/www/laravel/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/laravel/bootstrap/compiled.php:8423
I've read this has something to do with permissions but chmod -R 775 storage
didn't help at all.
It also may be SELinux. (Centos, RedHat)
Determine status of SElinux on terminal:
If status is enabled, write command to disable SElinux
Or you may execute this command
$ sudo setenforce 0
This error can be fixed by disabling Linux.
Check if it has been enabled
sestatus
You try..
setenforce 0
I wasn't too keen on changing my folder permissions to 777. Here's how I went about fixing this issue.
First, I changed the user who is running the web server on my local machine(I run nginx, but the principles apply everywhere):
Afterwards, I created another
index.php
file under thepublic/
folder to find out who was running my php-fpm version and where I would go about changing that:Reloading the page, I found out that
www-data
was the user(under the environment section). I also found out I was running php 7.1. I proceeded to change the user:Finally, I gave the following permissions to folders:
Now, I made sure that I was the owner of the folders by using a simple:
If you set the server and php-fpm users to yourself and the folders are owned by root for example, then you will keep encountering this issue. This can happen if you did a
sudo laravel new <project>
as root. In that case, make sure you use a recursivechown
command on your project to change theuser:group
settings. In most default cases,www-data
is the main setting for the server and php, in that case it's a matter of making sure the folder isn't out ofwww-data
's reach.My project is setup in my home directory. On Ubuntu 16.04 and Laravel 5.5.
Fixed my problem with this command in centos 7.6 Server
(on Ubuntu) : Can be solved in 2 simple steps :
And
Had this issue and found this and it solved the issue.