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

tnort's avatar
Level 4

Storage/Cached files permission erros

Hi,

Did you guys have file permission issues and how did you fix them?

My setup:

  1. the user I am using to deploy the app owns the project and I added it to the sudoer, www-data and other related groups
  2. the www-data user runs the app
  3. I gave all files 644, and all directories 755
  4. the bootstrap/cache and storage/ files I recursively gave 755
# Set ownership for the entire application to deploy-user
sudo chown -R deploy-user:deploy-user /path/to/your/laravel/application

# Set ownership for writable directories to www-data
sudo chown -R www-data:www-data /path/to/your/laravel/application/storage
sudo chown -R www-data:www-data /path/to/your/laravel/application/bootstrap/cache

# Set file permissions for the entire application
sudo find /path/to/your/laravel/application -type f -exec chmod 644 {} \;
sudo find /path/to/your/laravel/application -type d -exec chmod 755 {} \;

# Set writable permissions for the storage and cache directories
sudo chmod -R 775 /path/to/your/laravel/application/storage
sudo chmod -R 775 /path/to/your/laravel/application/bootstrap/cache

For some reason, I sometimes fail to run php artisan clear commands while other times the application itself fails to create cached files or log files which breaks the application. I cannot seem to find a middle ground. Although I update the fileSystem config to:

'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'permissions' => [
                'file' => [
                    'public' => 0664,
                    'private' => 0600,
                ],
                'dir' => [
                    'public' => 0775,
                    'private' => 0700,
                ],
            ],
        ],

it still keeps on failing.

If anyone had similar issues how did you fix it?

0 likes
0 replies

Please or to participate in this conversation.