Skip to content

Instantly share code, notes, and snippets.

@zeropointdevelopment
Created December 27, 2013 05:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zeropointdevelopment/8142897 to your computer and use it in GitHub Desktop.
Save zeropointdevelopment/8142897 to your computer and use it in GitHub Desktop.
[WordPress] Code from our blog post Recursively Set WordPress File Permissions - http://www.limecanvas.com/recursively-set-wordpress-file-permissions/
#!/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