ONE NET WIKI Free and professional IT Wiki

How to fix the error of Laravel: laravel.log could not be opened.

2018-10-13 ONE NET WIKI


When you create your first laravel project and visit it, you will probably get an error as follows:

The stream or file "/var/www/html/" could not be opened: failed to open stream: Permission denied.

storage permission.png

As mentioned in Laravel Documentation, after installing Laravel, you may need to configure some permissions. Directories within the  storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.

You can change the permission of both directories by the folowing two ways:

chown -R 777 [Not Recommend]

You can set two directories to 777.

chmod -R 777 storage
chmod -R 777 bootstrap/cache

777 means anyone (Owner, Group and Others) can have full privilledges on both directories. This is dangerous.

chown -R $user:www-data [Recommend]

You should change directory ownership so that your current user as owner and the webserver user (www-data, apache, ...) as the group.

// set current user as owner and the webserver user as the group
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
// set directory permission to be 775
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Editor's Note: All the articles in this website are original. If reproduced, please indicate the source and link.
All Comments (0)
Expand to publish a comment

Web Development

Web Management

Web Marketing

Web Security