---
name: choutos/fix-log-permissions
source: https://app.decimal.ai/s/choutos-fix-log-permissions@1/SKILL.md
source_sha256: bee3e124675c
---

# Fix Laravel Log Permissions

## Symptoms
- `UnexpectedValueException: .../storage/logs/laravel.log Permission denied`
- Application returns 500 errors after deployment
- Log file owned by `root` instead of `www-data`

## Fix

```bash
# Fix ownership
sudo chown -R www-data:www-data /var/www/storage/logs/

# Restart PHP-FPM (adjust version as needed)
sudo systemctl restart php8.2-fpm
```

Or use the script: `scripts/fix-perms.sh <ssh-host>`

## Root Cause

Deployment runs as root, creating or modifying log files with root ownership.
The web server (www-data) then can't write to them.

## Prevention

Add to post-deploy hook:
```bash
chown -R www-data:www-data /var/www/storage/logs/
```