How to fix Error: laravel.log could not be opened?

How to fix Error: laravel.log could not be opened?

Laravel failed to open stream permission-denied storage, logs. In this tutorial, you will learn, how to solve storage/logs/laravel.log” could not be opened: failed to open stream: permission denied.

This fix log error Laravel tutorial will cover the following topics:

  • How to fix Error: laravel.log could not be opened?
  • laravel storage/logs” and it could not be created: permission denied
  • laravel failed to open stream: permission denied
  • 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

While you working with laravel framework and you face some errors related to laravel failed to open stream permission denied storage, laravel failed to open stream permission denied log, laravel session failing to open stream permission denied.

So this tutorial will help you to solve these errors.

For Ubuntu/Linux Users

If you face laravel storage link permission denied. So, this tutorial will help you to give permission for linking the public storage directories 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 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 Posts

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *