Customizing WordPress permissions when creating new site #628
Replies: 1 comment
-
|
There's no pre-create hook for site permissions in CloudPanel — Three options depending on how much you want to automate: 1. Post-creation script — simplest if you provision sites with #!/usr/bin/env bash
set -euo pipefail
SITE_USER="$1"
DOCROOT="/home/${SITE_USER}/htdocs"
# 0755 for directories, 0644 for files
find "${DOCROOT}" -type d -exec chmod 0755 {} \;
find "${DOCROOT}" -type f -exec chmod 0644 {} \;
# Make sure ownership is the site user, in case anything was placed by root
chown -R "${SITE_USER}:${SITE_USER}" "${DOCROOT}"Run it as 2. ACL defaults — applies to anything created afterwards under the docroot: # After site creation, once per site:
setfacl --default --modify u::rwx,g::rx,o::rx /home/<site-user>/htdocs
setfacl --default --modify m::rx /home/<site-user>/htdocs
3. echo 'umask 022' >> /home/<site-user>/.bashrcA define( 'FS_CHMOD_DIR', 0755 );
define( 'FS_CHMOD_FILE', 0644 );That's what to combine with options 1 or 2 if your sites are WordPress — together they cover the full create-path on a stock CloudPanel install. For provisioning at scale, options 1+2+the wp-config constants together give you deterministic perms without needing CloudPanel itself to grow a hook. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What is the best approach if I want all WordPress folders to be 0755 and all files to be 0644 (aside from the CLI) whenever a new site is created? Is there any way to pre-configure this?
Beta Was this translation helpful? Give feedback.
All reactions