[How to] Restore default permissions trong virtual host directory

Vấn đề.

Một số file và thư mục nằm trong thư mục Domain Virtual Host bị “mất” các permission cần thiết.

Một số trong đó thuộc quyền sở hữu của apache user và root user. Thông báo “Permission Denied” và “Access Denied” xuất hiện khi người dùng thử upload file lên server thông qua FTP Manager hoặc FTP Client.

Tiến trình backup cũng failed và xuất hiện lỗi.

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

Hoặc

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

Hướng xử lý.

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

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

Trong command này, domain.ldt sẽ là domain cần restore permission và ftp_user_name là tên ftp user.

Sử dụng cú pháp dưới đây để query thông tin 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 |
+---------------------+----------------------+

#

Plesk 10.4

Chạy command theo bên dưới với quyền privileges và download file shell script theo link archived shell script . Tiến hành unzip và chạy theo cú pháp domain là đối số như bên dưới.

# wget https://kb.plesk.com/Attachments/kcs-20264/recover_plesk_directories-10.4.zip
# unzip recover_plesk_directories-10.4.zip
# sh recover_plesk_directories-10.4 example.com

Plesk 11.0

Cũng tương tự như Plesk 10.4
# wget https://kb.plesk.com/Attachments/kcs-20264/recover_plesk_directories.zip
# unzip recover_plesk_directories.zip
# sh recover_plesk_directories.sh example.com

Plesk 11.5, 12 and 12.5

Đảm bảo microupdate đã được cài đặt.

Chạy lệnh sau với quyền superuser privileges.

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

Thông tin bổ sung.

Cấu trúc thư mục Virtual Host có thể xem tại đây Virtual Host Structure .

BÌNH CHỌN:

Hãy bình chọn 5 sao nếu bạn tìm thấy nội dung hữu ích.

Xếp hạng: 0 / 5. Phiếu bầu: 0

Cảm ơn bạn đã bình chọn.

    YÊU CẦU TƯ VẤN DỊCH VỤ