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.
Run following commands and you can add
sudo
at starting of command depends on your system:Never set a directory to 777. you should change directory ownership. so set your current user that you are logged in with as owner and the webserver user (www-data, apache, ...) as the group. You can try this:
then to set directory permission try this:
Update:
Webserver user and group depend on your webserver and your OS. to figure out what's your web server user and group use the following commands. for nginx use:
ps aux|grep nginx|grep -v grep
for apache use:
ps aux | egrep '(apache|httpd)'
For all Centos 7 users on a Laravel context, there is no need to disable Selinux, just run these commands:
Lastly, make sure your hosts, ips and virtual hosts are all correctly for remote accessing.
Selinux is intended to restrict access even to root users, so only the necessary stuff might be accessed, at least on a generalist overview, it's extra security, disabling it is not a good practise, there are many links to learn Selinux, but for this case it is not even required.
In my particular case I had a config file generated and cached into the
bootstrap/cache/
directory so my steps where:rm bootstrap/cache/*.php
Create a new
laravel.log
file and apply the update of the permissions on the file using:chmod -R 775 storage
In Laravel, you should set ACL on
storage
andcache
directory so that web server user can read/write on the directory. Open a new terminal and run following:References:
https://symfony.com/doc/3.4/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd
https://linux.die.net/man/1/setfacl
try this