Articles in this section

How to restore the default file / directory permissions located inside domain's document root in Plesk for Linux

kb: how-to Plesk for Linux

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)

For specific domain
  1. Connect to your Plesk server via SSH.
  2. 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 |
    +-------------+----------+--------------------------------------+

  3. 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 fs utility:

      # 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 {} \;

For all domains
  1. Connect to your Plesk server via SSH.
  2. 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

  3. 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

  4. 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

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.