Laravel - The stream or file "/var/www/laravel/storage/logs/laravel.log" could not be opened: failed

Jackbox

Active Member
Jan 2, 2016
197
96
74
Oh, so much fun!

Code:
Whoops, looks like something went wrong.
The stream or file "/var/www/laravel/storage/logs/laravel.log" could not be opened: failed to open stream:
Permission denied
in StreamHandler.php (line 107)

Not a big deal, there are only a few possibilities here.
1. File access rights are not suitable for the Laravel framework which can be fixed by following advice here.
Code:
sudo chown -R www-data:www-data /path/to/your/laravel/root/directory
sudo usermod -a -G www-data ubuntu
sudo find /path/to/your/laravel/root/directory -type f -exec chmod 644 {} \;
sudo find /path/to/your/laravel/root/directory -type d -exec chmod 755 {} \;

Code:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

2. In some cases this could be the result of SELinux enforcing security. To fix this:
Code:
sudo su -
nano /etc/selinux/config
Find SELINUX= and change this value from enforcing to permissive.
Reboot

If you opt for SELinux remaining enforcing, you are more than welcome to follow this from laravel.io:
Code:
update SELinux filesystem policies and set some permissions
[vagrant@localhost www]$ cd /var/www/testsite
[root@localhost testsite]$ sudo chmod 1777 storage
[root@localhost testsite]$ sudo chmod 1777 bootstrap/cache
[root@localhost testsite]$ sudo chcon -Rv -t httpd_sys_rw_content_t storage
[root@localhost testsite]$ sudo chcon -Rv -t httpd_sys_rw_content_t bootstrap/cache

Browse your new laravel site:
Open a browser. Go to http://10.40.10.110 (or whatever your IP was)

Now go build something
 
Last edited:
Top