Laravel log permission denied

For a typical Ubuntu server running Nginx or Apache with PHP-FPM:

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache

sudo chmod -R 775 storage
sudo chmod -R 775 bootstrap/cache

Here:

  1. $USER is the Linux user currently logged in.
  2. www-data is commonly the user/group used by the web server on Ubuntu.
  3. 775 gives the owner and group read, write, and execute permissions.
  4. Other users receive read and execute permissions only.

Laravel needs write access to these directories for logs, cache, compiled views, sessions, and other generated files.

If Laravel still reports permission errors, confirm which user PHP is running as before changing permissions further.

ps aux | grep php

For Nginx, the configured worker user can also be checked with:

grep "^user" /etc/nginx/nginx.conf

The goal is to give Laravel the permissions it actually needs rather than solving permission problems by making directories globally writable.

Contact

Want to get in touch?

If you want to talk about a project, a software or IT role, something you have built, or a system you want to improve, send me a message.

I read the messages myself.

Thank you. Your message has been sent.