Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
🔧 Fixes WordPress upload directories permissions being set to root, use it with crontab.
# Set this to your server's owner user (normally www-data)
# Set this to the path to your wp-content
# Gets current year and month numbers
year=`date +%Y`
month=`date +%m`
# Creates the directories
mkdir "$wp_content_path/uploads"
mkdir "$wp_content_path/uploads/$year"
mkdir "$wp_content_path/uploads/$year/$month"
# Updates both the uploads, current year and current month directories
chown $user "$wp_content_path/uploads"
chown $user "$wp_content_path/uploads/$year"
chown $user "$wp_content_path/uploads/$year/$month"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment