Applicable to:
- Plesk for Linux
Question
How to reset the default file / directory permissions located inside domain's document root?
Answer
Note: The default permissions inside domain's document root directory are:
directories - 755 (Read, Write, Execute for owner, Read and Execute for group and others)
files - 644 for files (Read and Write for owner, Read for group and others)
- Connect to your Plesk server via SSH.
-
Obtain the document root directory and the system username of a domain:
Note: Replace example.com with a domain name in question.
# plesk db "select name, login, www_root from domains join hosting on domains.id=hosting.dom_id join sys_users on hosting.sys_user_id=sys_users.id where name='example.com'"
Sample output:
CONFIG_TEXT: +-------------+----------+--------------------------------------+
| name | login | www_root |
+-------------+----------+--------------------------------------+
| example.com | john_doe | /var/www/vhosts/example.com/httpdocs |
+-------------+----------+--------------------------------------+ - Using the information from step 2, replace the values (in bold) in the commands below and run them:
-
Set default permissions for directories:
# find /var/www/vhosts/example.com/httpdocs/ -type d -exec chmod 755 {} \;
-
Set default permissions for files:
# find /var/www/vhosts/example.com/httpdocs/ -type f -exec chmod 644 {} \;
-
Repair ownership with
plesk repair fsutility:# plesk repair fs -y example.com
or manually with the commands:
# find /var/www/vhosts/example.com/httpdocs/ -type f -exec chown john_doe:psacln {} \;
# find /var/www/vhosts/example.com/httpdocs/ -type d -exec chown john_doe:psacln {} \;
-
- Connect to your Plesk server via SSH.
-
Restore default permissions for websites' directories:
# plesk db -Ne "select www_root from hosting" | while read i; do find $i -type d -exec chmod 0755 {} \; ; done
-
Restore default permissions for websites' files:
# plesk db -Ne "select www_root from hosting" | while read i; do find $i -type f -exec chmod 644 {} \; ; done
-
Repair ownership for websites' files and directories:
# plesk repair fs -vhosts -y
Additional Information
To check file and directory permissions inside domain's document root, execute the following command. It will show files/directories with non-default permissions:
# plesk repair fs -vhosts -verbose -n
Comments
Please sign in to leave a comment.