Question
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?
Answer
NOTE: 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 (on RPM-based Linux distributions) will break websites, refer to the 'Fix SELinux context' tab to apply the fix for the servers with SELinux enabled. As an alternative, keep SELinux in the permissive mode for the correct website's working capacity.
1. Connect to the server via SSH
2. The location change can be done using transvhosts.pl
utility, run command with --help
argument to learn about it:
# plesk bin transvhosts.pl --help
3. To change virtual hosts location to /home/vhosts/
directory for example run the following command (replace /home/vhosts/
with the actual path to target directory):
# plesk bin transvhosts.pl --dest-dir /home/vhosts/ --correct-scripts
All virtual host content will be automatically moved to the new location.
Note: changing virtual host location will not affect backup restoration functionality. Content from backups will be restored to new custom location.
Warning: running restorecon
on the virtual host directory or its parent directory will revert this fix.
1. Connect to the server via SSH
2. Run the following commands to fix the SELinux context for the custom virtual host directory (make sure to replace /home/vhosts/
with the actual path to virtual host directory):
# chcon -R system_u:object_r:httpd_sys_content_t:s0 /home/vhosts/
# find /home/vhosts/ -maxdepth 2 -type d -name logs -exec chcon -R root:object_r:httpd_log_t:s0 {} ;
# find /home/vhosts/ -maxdepth 2 -type d -name bin -exec chcon -R system_u:object_r:bin_t:s0 {} ;
# find /home/vhosts/ -maxdepth 3 -path '*/etc/*' -name resolv.conf -exec chcon system_u:object_r:net_conf_t:s0 {} ;
Note: vote for these steps to be automated in the Plesk UserVoice portal. The top-ranked suggestions are likely to be included in the next versions of Plesk.