Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marbobo's avatar

Permission Denied on storage/logs/laravel.log

Hi,

I have problem running my laravel project in linux ( fedora 23 lxde 64bit). It was working perfectly on my windows 7.

The page always always shows blank page with error 500. I try to catch exemption on the public/index.php and this error show.

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

below is the output when I run this command under my root dir drwxrwxr-x. 12 apache apache 4096 Apr 5 03:59 app -rwxrwxr-x. 1 apache apache 1646 Apr 5 03:59 artisan drwxrwxr-x. 3 apache apache 4096 Apr 5 03:59 bootstrap -rw-rw-r--. 1 apache apache 1457 Apr 5 03:59 composer.json -rw-rw-r--. 1 apache apache 124481 Apr 5 03:59 composer.lock drwxrwxr-x. 2 apache apache 4096 Apr 5 03:59 config drwxrwxr-x. 5 apache apache 4096 Apr 5 03:59 database -rw-rw-r--. 1 apache apache 616 Apr 5 04:36 .env -rw-rw-r--. 1 apache apache 622 Apr 5 03:59 .env.example drwxrwxr-x. 8 apache apache 4096 Apr 5 06:28 .git -rw-rw-r--. 1 apache apache 61 Apr 5 03:59 .gitattributes -rw-rw-r--. 1 apache apache 156 Apr 5 03:59 .gitignore -rw-rw-r--. 1 mbesinga mbesinga 1383 Apr 5 06:27 gulpfile.js drwxrwxr-x. 2 apache apache 4096 Apr 5 06:27 gulpscripts drwxrwxr-x. 779 apache apache 32768 Apr 5 04:08 node_modules -rw-rw-r--. 1 apache apache 159 Apr 5 03:59 package.json -rw-rw-r--. 1 apache apache 870 Apr 5 03:59 phpunit.xml drwxrwxr-x. 6 apache apache 4096 Apr 5 04:37 public -rw-rw-r--. 1 apache apache 441 Apr 5 03:59 README.md drwxrwxr-x. 5 apache apache 4096 Apr 5 03:59 resources -rw-rw-r--. 1 apache apache 567 Apr 5 03:59 server.php drwxrwxrwx. 5 apache apache 4096 Apr 5 03:59 storage drwxrwxr-x. 2 apache apache 4096 Apr 5 03:59 tests drwxrwxr-x. 33 apache apache 4096 Apr 5 06:30 vendor

below is my vhost `` <VirtualHost *:80> DocumentRoot "/var/www/html/project_name/public/" ServerName project_name.dev DirectoryIndex index.php index.html

CustomLog "/etc/httpd/logs/project_name.dev-access_log" combined
ErrorLog "/etc/httpd/logs/project_name.dev-error_log"

<Directory "/var/www/html/project_name/public">
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

``

0 likes
14 replies
Phinocio's avatar

You need to change the permissions on storage/

chmod -R 777 storage/

Should do the trick.

4 likes
spekkionu's avatar

Check the owner and permissions on the /var/www/html/project_name/storage/logs/laravel.log file. It should be writable by the same user the web server is running as (which looks like apache on your server).

One common problem is if the log file is created by an artisan command it will have the user you ran the command as the owner and may not be writable by the web server. If this is the case either change the owner or permissions so the web server can write to the file.

Alternatively you can change the user the web server is running as to match the one you run artisan commands with.

2 likes
eclypse's avatar

@spekkionu what if the laravel.log file does not exist? I have been having this same issue so I copied the storage/logs folder from a fresh install of Laravel and pasted into my current project. How can there be permission issues if the file is no longer there? Its not just the log file either. If I change the permissions to 777 (which I know I should not do. I was just testing it), the log file error goes away but I then get an permissions error for a storage/framework/views file that is also not there because I cleared that directory. What am I missing?

MartinS's avatar

If you are using Homestead and have upgraded PHP from say 7.0 to 7.1 it might be that you need to update a PHP related config file.

Edit this file: /etc/php/7.1/fpm/pool.d/www.conf

Make sure you have these two lines in the file:

user = vagrant

group = vagrant

In the default PHP installation this file has the following setting which doesn't work well in Homestead:

user = www-data

group = www-data

5 likes
pettturu's avatar

Hi, I'm having this issue on daily basis on my production server. Probably the server restart (or whatever) loses the permissions. So, almost daily I need to run shell_exec("sudo chown -R www-data ."); shell_exec("sudo chmod -R 755 ./storage"); in ordrer to get laravel to log properly.

Running Ubuntu 17.10 (GNU/Linux 4.13.0-16-generic x86_64) with nginx.

Any help to solve this is appreciated.

JeroenVranken's avatar

@MartinS Thank you soooo much! I literally spent 8 hours trying to solve this permission error which occurred after upgrading to php 7.2

dannys's avatar

For all Centos 7 users there is no need to disable Selinux, just follow this short guide and it will get the job done https://www.linkedin.com/pulse/selinux-laravel-framework-rodrigo-alvares/ Lastly, make sure your hosts, ips and virtual hosts are all correct for remote accessing. I am not sure if fedora, or debian has selinux or not, but just make apache/www-data the owner of eveyrfolder, check your firewall and eveything should be good to go.

1 like
Jukka's avatar

This problem still persists! And provided solutions that I found did not help.

User case: Virtual linux ubuntuserver (LAMP) with laravel and stuff Mac OSX with telenet connection to server

php-srcipts run as www-data shell scripts run via telnet run as my username jukka

If error log is created by shell script, it becomes to jukka:www-data and then when I try to open the project in my browser, it fails because www-data cannot write to that file.

  • my user is already part of www-data -group
  • i cannot change the file permissions because I don't know wow and when the log file is created. And new files are created every day
  • changing folder permissions does not help
  • I cannot connect to my server as www-data or change my apache to run as jukka, that's the wrong solution

Aaaand instantly found a solution from here: https://stackoverflow.com/a/49379249/1635217

2 likes
marbobo's avatar
Level 12

Lol! So it takes me 3 years in order to fix this? haha the issue was on selinux. i face this exactly same error on my fresh installation of fedora 30 but on nginx not apache.. thank @pascual for the selinux info. I just have disabled it for now but i will try the link you gave.

marbobo's avatar
marbobo
OP
Best Answer
Level 12

figure out some better answer rather than disabling the selinux. I just set the nginx to permissive mode. its works but im not sure in apache.

semanage permissive -a httpd_t

2 likes
aremuopomulero@gmail.com's avatar

inside the config/logging.php in the "channels" associative array add permissions key to your "single" and "daily" set it to 0777 as an octal value not as string so it will look like this 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', 'permission' => 0777, ] *using string will convert the value to an integer and the chown() method in PHP takes in octal value so leading it with 0 will make it an octal value.

1 like

Please or to participate in this conversation.