Last active
November 8, 2019 17:04
-
-
Save juanjosezg/79b2680da64396cdb37250d85606da0b to your computer and use it in GitHub Desktop.
Wordpress Permissions Dreamhost
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/bash | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Michael Conigliaro (https://gist.github.com/macbleser/9136424) | |
# | |
WP_ROOT=${1:-.} # <-- wordpress root directory, current directory by default | |
[ -e "$WP_ROOT/wp-config.php" ] || { echo "Usage: $0 /path/to/wordpress"; exit; } # <-- detect that the directory is a wordpress root | |
echo 'Reset to safe defaults:' | |
echo ' - 775 Directories' | |
echo ' - 644 Files' | |
find ${WP_ROOT} -type d -exec chmod 755 {} \; | |
find ${WP_ROOT} -type f -exec chmod 644 {} \; | |
echo 'Allow wordpress to manage wp-config.php (but prevent world access)' | |
chmod 660 ${WP_ROOT}/wp-config.php | |
echo 'Allow wordpress to manage .htaccess' | |
touch ${WP_ROOT}/.htaccess | |
chmod 664 ${WP_ROOT}/.htaccess | |
echo 'allow wordpress to manage wp-content' | |
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \; | |
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \; | |
# chmod +x wordpress-perms.sh | |
# ./wordpress-perms.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment