Laravel – storage/logs/laravel.log Could Not be Opened

Laravel could not be opened failed to open stream permission denied. In this tutorial, i am going to show you simple and easy solutions on storage/logs/laravel.log” could not be opened: failed to open stream: permission denied with windows, linux ubuntu, and mac users.

Through this tutorial, i will cover the following issue on laravel applications:

  • laravel log file permission denied
  • laravel storage/logs” and it could not be created: permission denied
  • the stream or file /var/www/html/storage/logs/laravel.log could not be opened in append mode
  • storage/logs/laravel.log” could not be opened: failed to open stream: permission denied ubuntu
  • laravel failed to open stream: permission denied
  • laravel.log could not be opened in append mode windows
  • could not be opened in append mode: failed to open stream: permission denied laravel
  • file_put_contents failed to open stream: permission denied laravel 8
  • failed to open stream: permission denied laravel file upload

Laravel could not be opened failed to open stream permission denied

I will provide 3 solutions for ubuntu, mac and windows users to laravel could not be opened failed to open stream permission denied

  • For Ubuntu/Linux Users
  • For mac OSX Users
  • For Windows Users

For Ubuntu/Linux Users

If you face laravel storage link permission denied. So, this tutorial will help you to give permission for linking public storage directory in laravel app.

It turns out I was missing a view directories in laravel_root/storage/. In order to fix this, all I had to do was:

  1. cd {laravel_root}/storage
  2. mkdir -pv framework/views app framework/sessions framework/cache
  3. cd ..
  4. chmod 777 -R storage
  5. chown -R www-data:www-data storage

Then, You need to adjust the permissions of storage and bootstrap/cache.

  1. cd into your Laravel project.
  2. sudo chmod -R 755 storage
  3. sudo chmod -R 755 bootstrap/cache

For mac OSX Users

How to set file permissions for Laravel 5 on mac OSX:

Setting permissions

There are different approaches to it, but when working locally or on a development environment, i like it when my user shares ownership with Apache (the web server).

Execute the following command on terminal:

sudo chown -R $USER:_www /path/to/laravel/install

This command changes the owner / group to be your username and the web server.

Now, you need to give the correct folders the permissions they need, issue the follow commands:

sudo find /path/to/laravel/install -type f -exec chmod 664 {} \; 
sudo find /path/to/laravel/install -type d -exec chmod 775 {} \;

Setting web server files permission

Now, you need to make it so that the web server can write to the files/folders it needs to, such as the app/ and storage/folders. Issue the following commands:

cd /path/to/laravel/install
sudo chgrp -R _www storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

For Windows Users

Create these directories if they don’t exist in laravel:

  • storage/framework/cache
  • storage/framework/sessions
  • storage/framework/views

Then

  • delete bootstrap/cache files

Test if it works, if not, try giving the correct permissions to the storage folder: chmod -R 775 storage/

Recommended Laravel Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published.