fix permision deploy
This commit is contained in:
85
debug-permissions.sh
Executable file
85
debug-permissions.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Debug script untuk diagnosa permission issues
|
||||
# Jalankan di server untuk check masalah permission
|
||||
|
||||
PROJECT_PATH=${1:-"/var/www/pupr"}
|
||||
|
||||
echo "🔍 Debugging permissions for: $PROJECT_PATH"
|
||||
echo "================================================="
|
||||
|
||||
# Check if path exists
|
||||
if [ ! -d "$PROJECT_PATH" ]; then
|
||||
echo "❌ Project path not found: $PROJECT_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$PROJECT_PATH"
|
||||
|
||||
echo "📊 Current User & Groups:"
|
||||
echo "Current user: $(whoami)"
|
||||
echo "Web server user: $(ps aux | grep -E 'apache|nginx|httpd' | grep -v grep | head -1 | awk '{print $1}')"
|
||||
echo ""
|
||||
|
||||
echo "📁 Directory Ownership & Permissions:"
|
||||
echo "Project root:"
|
||||
ls -la . | head -5
|
||||
echo ""
|
||||
echo "Storage directory:"
|
||||
ls -la storage/
|
||||
echo ""
|
||||
echo "Storage/framework:"
|
||||
ls -la storage/framework/ 2>/dev/null || echo "storage/framework/ not found"
|
||||
echo ""
|
||||
echo "Bootstrap/cache:"
|
||||
ls -la bootstrap/cache/ 2>/dev/null || echo "bootstrap/cache/ not found"
|
||||
echo ""
|
||||
|
||||
echo "🔐 Permission Analysis:"
|
||||
# Check critical directories
|
||||
directories=("storage" "storage/framework" "storage/framework/views" "storage/framework/cache" "storage/logs" "bootstrap/cache")
|
||||
|
||||
for dir in "${directories[@]}"; do
|
||||
if [ -d "$dir" ]; then
|
||||
perm=$(stat -c "%a" "$dir")
|
||||
owner=$(stat -c "%U:%G" "$dir")
|
||||
echo "✅ $dir: $perm ($owner)"
|
||||
else
|
||||
echo "❌ $dir: NOT FOUND"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "🧪 Write Test:"
|
||||
# Test write permissions
|
||||
if [ -w "storage/framework/" ]; then
|
||||
echo "✅ storage/framework/ is writable"
|
||||
# Try creating a test file
|
||||
if touch storage/framework/test_write_$(date +%s).tmp 2>/dev/null; then
|
||||
echo "✅ Can create files in storage/framework/"
|
||||
rm -f storage/framework/test_write_*.tmp
|
||||
else
|
||||
echo "❌ Cannot create files in storage/framework/"
|
||||
fi
|
||||
else
|
||||
echo "❌ storage/framework/ is NOT writable"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "⚙️ SELinux Status (if applicable):"
|
||||
if command -v getenforce &> /dev/null; then
|
||||
echo "SELinux: $(getenforce)"
|
||||
if [ "$(getenforce)" = "Enforcing" ]; then
|
||||
echo "⚠️ SELinux is enforcing - may need additional configuration"
|
||||
echo "Try: sudo setsebool -P httpd_unified on"
|
||||
fi
|
||||
else
|
||||
echo "SELinux not installed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📋 Recommended Actions:"
|
||||
echo "1. Fix ownership: sudo chown -R www-data:www-data $PROJECT_PATH"
|
||||
echo "2. Fix permissions: sudo chmod -R 775 $PROJECT_PATH/storage/"
|
||||
echo "3. Clear cache: php artisan view:clear"
|
||||
echo "4. If SELinux: sudo setsebool -P httpd_unified on"
|
||||
Reference in New Issue
Block a user