Fix Error: laravel.log could not be opened?

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.

In this guide, we will cover the following topics:

  • the stream or file /var/www/html/storage/logs/laravel.log could not be opened in append mode
  • laravel storage/logs” and it could not be created: permission denied
  • the stream or file /storage/logs/laravel log could not be opened in append mode
  • 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.

Here are three different solutions for the error the stream or file “/var/www/storage/logs/laravel.log” could not be opened in append mode for three different OS systems:

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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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