Skip to content

Instantly share code, notes, and snippets.

@ocReaper
Forked from macbleser/wp-permissions-script
Last active November 25, 2021 14:07
Show Gist options
  • Save ocReaper/2ae44add42c3ed4513e1055c30a78eb4 to your computer and use it in GitHub Desktop.
Save ocReaper/2ae44add42c3ed4513e1055c30a78eb4 to your computer and use it in GitHub Desktop.
Bedrock WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures Bedrock based WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro, Mac Bleser, Ákos Resch
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
WS_GROUP=changeme # <-- webserver group
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;
# allow wordpress to manage .htaccess
touch ${WP_ROOT}/web/.htaccess
chgrp ${WS_GROUP} ${WP_ROOT}/web/.htaccess
chmod 664 ${WP_ROOT}/web/.htaccess
# allow wordpress to manage wp-content
find ${WP_ROOT}/web/app -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/web/app -type d -exec chmod 775 {} \;
find ${WP_ROOT}/web/app -type f -exec chmod 664 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment