Skip to content

Instantly share code, notes, and snippets.

@khoipro
Created June 9, 2026 02:16
Show Gist options
  • Select an option

  • Save khoipro/8fd5e07b25ed8a5904257b0c0b969ad3 to your computer and use it in GitHub Desktop.

Select an option

Save khoipro/8fd5e07b25ed8a5904257b0c0b969ad3 to your computer and use it in GitHub Desktop.
Quick fix site permission (without wp-content/uploads/ folder)
#!/usr/bin/env bash
set -euo pipefail
SITE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--site=*)
SITE="${1#*=}"
shift
;;
--site)
SITE="${2:-}"
shift 2
;;
*)
echo "Usage: $0 --site=<site-name>" >&2
exit 1
;;
esac
done
if [[ -z "$SITE" ]]; then
echo "Missing required flag: --site" >&2
exit 1
fi
ROOT="/home/ubuntu/webapps/$SITE"
UPLOADS="$ROOT/wp-content/uploads"
if [[ ! -d "$ROOT" ]]; then
echo "Site path not found: $ROOT" >&2
exit 1
fi
sudo find "$ROOT" \
\( -path "$UPLOADS" -o -path "$UPLOADS/*" \) -prune -o \
-exec chown www-data:www-data {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment