- Introduce `cache-configuration.md` for detailed instructions on cache setup, permission troubleshooting, and best practices. - Add `cache-permissions-quick-fix.md` for concise resolutions to common permission errors. - Include a detailed `FILECACHE_PERMISSION_FIX_PLAN.md` outlining solutions for permission-related issues. - Enhance `docker-entrypoint.sh` with permission fixes for multi-user caches. - Update `Makefile` with cache clear commands for local and staging environments. - Improve `FileCache` for graceful degradation on permission errors, ensuring reliability under multi-user scenarios.
2.0 KiB
2.0 KiB
Cache Permissions Quick Fix
Problem
chown: invalid user: 'appuser:appuser'
Der User appuser existiert nicht im Container, oder es wird ein anderer User verwendet.
L?sung: Dynamischer Fix
Schritt 1: Ermittle den korrekten User
# Pr?fe welcher User verwendet wird
docker exec staging-app whoami
docker exec staging-app id
# Pr?fe PHP-FPM Konfiguration
docker exec staging-app grep "^user = " /usr/local/etc/php-fpm.d/*.conf
Schritt 2: Fix Berechtigungen (automatisch)
# Automatisch - ermittle User aus PHP-FPM Config
docker exec -it --user root staging-app bash -c '
USER=$(grep "^user = " /usr/local/etc/php-fpm.d/*.conf 2>/dev/null | head -1 | cut -d"=" -f2 | tr -d " ;")
[ -z "$USER" ] && USER="www-data"
echo "Using user: $USER"
chown -R $USER:$USER /var/www/html/storage/cache
chmod -R 775 /var/www/html/storage/cache
'
Schritt 3: Fix existierende Dateien
docker exec -it --user root staging-app bash -c '
USER=$(grep "^user = " /usr/local/etc/php-fpm.d/*.conf 2>/dev/null | head -1 | cut -d"=" -f2 | tr -d " ;")
[ -z "$USER" ] && USER="www-data"
find /var/www/html/storage/cache -type f -exec chmod 644 {} \;
find /var/www/html/storage/cache -type d -exec chmod 775 {} \;
chown -R $USER:$USER /var/www/html/storage/cache
echo "Fixed permissions for user: $USER"
'
Alternative: Manuelle Fix
Wenn du wei?t, welcher User verwendet wird:
F?r www-data (Production):
docker exec -it --user root staging-app chown -R www-data:www-data /var/www/html/storage/cache
docker exec -it --user root staging-app chmod -R 775 /var/www/html/storage/cache
F?r appuser (Development/Staging):
docker exec -it --user root staging-app chown -R appuser:appuser /var/www/html/storage/cache
docker exec -it --user root staging-app chmod -R 775 /var/www/html/storage/cache
Verifikation
# Pr?fe Berechtigungen
docker exec staging-app ls -ld /var/www/html/storage/cache
# Pr?fe Owner
docker exec staging-app ls -l /var/www/html/storage/cache | head -5