Naren
Naren

Reputation: 189

cannot open laravel.log - Permission error in ec2 Aws

I'm installing a fresh project in laravel, and the project has been successfully installed but there's error while browsing it.

UnexpectedValueException

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

Upvotes: 1

Views: 871

Answers (1)

Spholt
Spholt

Reputation: 4032

This will most likely be due to the permissions on the file itself.

When you installed that application, usually you would go about changing the ownership of the application with chown & the permissions to it's files with chmod.

However, even if you have done this on installation, the log file may not have existed at that time. To temporarily fix this, find the log file an update it's permissions (664 or 775 should do for now).

You would not want to do this manually every day however, so you would want to look for a solution to set the ownership or permissions when the log file is created.


Depending on your version of Laravel, you may be able to change the permissions on the log file in config/logging.php

    'single' => [
        'driver'     => 'single',
        'path'       => storage_path('logs/laravel.log'),
        'permission' => 0664,
        'level'      => 'debug',
    ],

    'daily' => [
        'driver'     => 'daily',
        'path'       => storage_path('logs/laravel.log'),
        'permission' => 0664,
        'level'      => 'debug',
        'days'       => 14,
    ],

Upvotes: 3

Related Questions