Last active
April 1, 2020 21:15
-
-
Save matpratta/5a4120c20c11954fcdb99475c43ddedd to your computer and use it in GitHub Desktop.
π§ Fixes WordPress upload directories permissions being set to root, use it with crontab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set this to your server's owner user (normally www-data) | |
user="www-data:www-data" | |
# Set this to the path to your wp-content | |
wp_content_path="/var/www/html/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