Jun 19, 2024
0
Level 4
Storage/Cached files permission erros
Hi,
Did you guys have file permission issues and how did you fix them?
My setup:
- 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
- the www-data user runs the app
- I gave all files 644, and all directories 755
- 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?
Please or to participate in this conversation.