Forked from zeropointdevelopment/code-snippet-1.bash
Last active
August 29, 2015 14:06
-
-
Save EddieDee/b2d08e70c10a13fd1a40 to your computer and use it in GitHub Desktop.
Reset wordpress files and folder permissions
This file contains 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/sh | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Wil Brown | |
# | |
# @uses /bin/sh scriptname.sh path | |
# @params text path to your WordPress folder from the www root e.g. / or /WordPress | |
# | |
ROOT=/home/sites/mydomainname.com/public_html #your site's root directory | |
if [ $# = 1 ]; | |
then | |
WP_ROOT=$ROOT$1; | |
#reset to safe defaults | |
find ${WP_ROOT} -type d -exec chmod 755 {} \; | |
find ${WP_ROOT} -type f -exec chmod 644 {} \; | |
#secure WordPress configuration file | |
chmod 440 ${WP_ROOT}/wp-config.php | |
#secure .htaccess | |
chmod 444 ${WP_ROOT}/.htaccess | |
echo "Done: Reset permissions in folder $WP_ROOT"; | |
else | |
echo "You need to provide the WordPress directory relative to the root $ROOT"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment