- Plesk for Linux
How to change virtual hosts locations in Plesk for Linux?
How to replicate website vhost and root document path during migration from a non-Plesk server?
Check the warnings before making any changes:
Warning: These actions may cause websites downtime depending on the number of domains and data to be copied to the new location. It is recommended to apply this during maintenance hours.
Warning: Changing vhosts directory with the SELinux enabled in Plesk will break websites. This is due to SELinux limitation: it stores absolute paths in its policies, /var/www/vhosts, in this case. As a workaround, set SELinux to permissive mode before applying steps below.
After changing vhosts folder, SELinux should be kept in the permissive mode for correct websites working capacity.
Fix SELinux context with
# chcon -R system_u:object_r:httpd_sys_content_t:s0 /home/vhosts/
# find /customdir/vhosts/ -maxdepth 2 -type d -name logs | xargs chcon -R root:object_r:httpd_log_t:s0
# find /customdir/vhosts/ -maxdepth 2 -type d -name bin | xargs chcon -R system_u:object_r:bin_t:s0
# find /customdir/vhosts/ -maxdepth 3 -name resolv.conf | grep 'etc/resolv.conf' | xargs chcon system_u:object_r:net_conf_t:s0
Warning: it will work until
restorecon will not be running against net vhost location or its parent directory.
The location change can be done using
# plesk bin transvhosts.pl --help
For example, to change virtual hosts location to
/customdir directory (replace /customdir with actual target directory):
# plesk bin transvhosts.pl --dest-dir /customdir --correct-scripts
All virtual host content will be automatically moved to the new location.
Changing virtual host location will not affect backup restoration functionality. Content from backups will be restored to new custom location.