How to restore default permissions in the virtual host directory

Created:

2016-11-16 12:45:41 UTC

Modified:

2017-08-16 16:22:57 UTC

14

Was this article helpful?


Have more questions?

Submit a request

How to restore default permissions in the virtual host directory

Applicable to:

  • Plesk for Linux

Question

Some files and directories under the domain virtual host directory have lost their permissions. Several are owned by the users apache or root .

The " Permission denied " or " Access denied " errors are shown, when attempting to upload files via the File Manager or an FTP client:

Unable to open the directory: Unable to find the directory /var/www/vhosts/example.com/httpdocs/somedir/: filemng failed: filemng: opendir failed: Permission denied
System error 13: Permission denied

The backup task fails and the logs show:

/bin/tar: httpdocs/path/to/a/file: Cannot open: Permission denied

OR

/bin/tar: httpdocs/path/to/a/file: Cannot stat: Permission denied

How to restore the default permissions for the virtual host?

Answer

For Plesk 9.5

# /usr/local/psa/admin/sbin/vhostmng --install-vhost --vhost-name=example.com --user-name=ftp_user_name --set-content-permissions

For Plesk 10.0-10.3

# /usr/local/psa/admin/sbin/vhostmng --install-vhost --vhost-name=example.com --user-name=ftp_user_name --www-root=/var/www/vhosts/example.com/httpdocs --cgi-bin-path=/var/www/vhosts/domain.tld/cgi-bin --set-content-permissions

In this command, domain.tld is the domain to restore permissions and ftp_user_name is the domain's FTP user.Use the following query to get the user:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -e"select d.name as domain, su.login as user_name from domains d, sys_users su, hosting h where d.id=h.dom_id and h.sys_user_id=su.id and d.name='example.com'"
+---------------+---------------+
| domain | user_name |
+---------------+---------------+
| example.com | ftp_user_name |
+---------------+---------------+
#

For Plesk 10.4

Run the following commands with superuser privileges to download the archived shell script . Unzip and execute it, providing the required domain name as an argument:

# wget https://support.plesk.com/hc/article_attachments/115004354025/recover_plesk_directories-10.4.zip
# unzip recover_plesk_directories-10.4.zip
# sh recover_plesk_directories-10.4 example.com

For Plesk 11.0

Run the following commands with superuser privileges to download the archived shell script . Unzip and execute it, providing the required domain name as an argument:

# wget https://support.plesk.com/hc/article_attachments/115004386349/recover_plesk_directories.zip
# unzip recover_plesk_directories.zip
# sh recover_plesk_directories.sh example.com

For Plesk 11.5, 12.0:

  1. Make sure that the latest microupdates are installed.

  2. Run the following command with the superuser privileges

    # /usr/local/psa/bin/repair --restore-vhosts-permissions

For Plesk 12.5 and Plesk Onyx:

  1. Make sure that the latest microupdates are installed.

  2. Run the following command with the superuser privileges

    # plesk repair fs example.com

Solution for Plesk in Windows is available in article #213376469

Additional information

The virtual host structure description can be found in the Virtual Host Structure page.

Here are the default permissions for Plesk 12.5 domain:

# ls -la /var/www/vhosts/example.com
total 16
drwx--x--- 4 admin123 psaserv 4096 Jan 5 13:14 .
drwxr-xr-x 13 root root 4096 Jan 5 13:14 ..
drwxr-x--- 6 admin123 psaserv 4096 Jan 5 13:14 httpdocs
drwx------ 2 admin123 root 4096 Jan 5 13:15 logs

# ls -la /var/www/vhosts/system/example.com
total 24
drwx--x--x 6 root psaserv 4096 Jan 5 13:14 .
drwxr-xr-x 7 root root 4096 Jan 5 13:14 ..
drwxr-x--- 2 root psaserv 4096 Jan 5 13:15 conf
drwxr-xr-x 2 root root 4096 Jan 5 13:14 etc
drwx------ 2 psaadm root 4096 Jan 5 13:15 logs
dr-xr-x--- 6 root psaserv 4096 Jan 5 13:14 statistics

Attachments:

Have more questions? Submit a request
Please sign in to leave a comment.