WordPress – How to Fix File and Folder Permissions – reset_wp_perm.sh

echo "v1.1, 2014120301"
echo ""
echo "Current directory is:"
read -p "Make sure you are in your WordPress directory, are you ? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
echo ""
echo "... Setting chmod 775 for all directories"
find ./ -type d -exec chmod 775 {} \;
echo "... Setting chmod 664 for all files"
find ./ -type f -exec chmod 664 {} \;
echo "... But setting chmod 664 for wp-config.php, though, assuming chown is set to ft
p user"
chmod 664 wp-config.php
echo "Type username"
read user
echo "... Setting chown $user:www-data for *"
chown -R $user:www-data *
#echo "... Setting chown to :www-data for wp-content/uploads"
#chown -R :www-data wp-content/uploads
echo "... Setting chown :www-data for .htaccess"
chown :www-data .htaccess
echo "... Setting chmod 644 for .htaccess"
chmod 644 .htaccess
echo ""
echo "Done"
echo ""
read -p "Also run fix for WordPress upgrade and file permissions issue ? (y/n) " -n 1
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
echo ""
echo "... Changing wp-content group ownership to www-data"
chgrp -R www-data wp-content
echo "... Making wp-content and all of its sub-directories group-writable"
chmod -R g+w wp-content
echo "... Newly-created files to be group-owned"
chmod g+s wp-content
echo "If necessary, add the following to the bottom of wp-config.php"
##/* Force direct file updating
##- taken from http://www.charleshooper.net/blog/wordpress-auto-upgrade-and-dumb-permi
##For more information, take a look at wp-admin/includes/file.php’s function get_files
echo "define('FS_METHOD', 'direct');"


Leave a Reply

Your email will not be published. Name and Email fields are required.


Comments Protected by WP-SpamShield for WordPress

This site uses Akismet to reduce spam. Learn how your comment data is processed.