💾 How to Change the Default vhosts Directory Path in Plesk (Step-by-Step Guide)
When you're running a Plesk server, you know that all your websites live inside the vhosts directory. By default, Plesk parks this at:
Code:
/var/www/vhosts
This guide will walk you through exactly how to do it safely, step by step.
1. 🔌 Connect to Your Server via SSH
First things first, you need to get into your server. Log in via SSH with your root user or another user with full sudo privileges.
Code:
ssh root@your_server_ip
2. 📝 Edit the Plesk Configuration File
Plesk's main configuration settings are stored in this file:
Code:
/etc/psa/psa.conf
Let's open it up using your favorite text editor, like nano or vi.
Code:
nano /etc/psa/psa.conf
Look inside the file for the line that defines the VHOSTS path. It will look like this:
Code:
VHOSTS=/var/www/vhosts
This is the line you need to change! Update it to your new, desired path. For example, if you're moving to a /data drive:
Code:
VHOSTS=/data/www/vhosts
All done? Great. Save the file and exit the editor. (If you're using nano, that's CTRL + X, then Y, and Enter to confirm).
3. 📂 Create the New Directory
Now that you've told Plesk where to look, you need to actually create that new directory. If it doesn't exist yet, make it now:
Code:
mkdir -p /data/www/vhosts
This next part is crucial! You must assign the correct ownership and permissions. Plesk and Apache need to be able to read and write to this new folder.
Code:
chown -R psaadm:psaadm /data/www/vhosts chmod -R 755 /data/www/vhosts
4. 🚚 Move Existing Website Files
Your new home is built, but all your stuff is still in the old house! It's time to move all your existing website files from the old vhosts directory to the new one. The cp command is perfect for this.
Code:
cp -r /var/www/vhosts/* /data/www/vhosts/
☕ This might take a few minutes depending on how much data you have. Once the copy is 100% complete, it's a good idea to rename the old directory (just in case you need it as a backup).
Code:
mv /var/www/vhosts /var/www/vhosts_backup
5. 🔄 Restart Plesk and Web Services
To make Plesk recognize all these changes, you need to give it a fresh start. Restart your web services.For Apache:
Code:
service apache2 restart
If you're using Nginx (often as a reverse proxy):
Code:
service nginx restart
And finally, restart the main Plesk management service:
Code:
service psa restart
6. 🔐 Verify Permissions and Website Access
Once everything is back online, let's double-check our work. It's vital to verify that the permissions and ownership on the new directory are still correct. You can test this again:
Code:
ls -la /data/www/vhosts
If you see anything that doesn't look right (e.g., owned by root), fix it immediately with the same commands from Step 3:
Code:
chown -R psaadm:psaadm /data/www/vhosts chmod -R 755 /data/www/vhosts
7. 🖥️ Update Domain Document Roots (If Needed)
In most cases, Plesk is smart enough to handle the change. But sometimes, individual domains might still be pointing to the old path, causing errors. If your sites are down, you'll need to update each domain's Document Root inside the Plesk UI.Log in to your Plesk Panel. Go to Websites & Domains. Find the affected domain and click Hosting Settings. Look for the Document Root field. Update the path to point to your new vhosts directory (e.g., /data/www/vhosts/domain.com/httpdocs).
Click OK or Apply to save your changes.
8. 🧐 Final Check
This is the moment of truth! After applying all these steps, open your websites in a browser. Click around and make sure everything loads correctly.If you see any errors (like a 404 or 500 error), it's time to check the logs. This will tell you exactly what's wrong.
Apache Logs:
Code:
/var/log/httpd/error_log
Nginx Logs:
Code:
/var/log/nginx/error.log
Plesk Logs:
Code:
/var/log/plesk/panel.log
Here's the quick recap:
Default Path: /var/www/vhosts Config File to Edit: /etc/psa/psa.conf Parameter to Change: VHOSTS Services to Restart: Apache, Nginx, and PSA
Once these steps are completed, Plesk will automatically use your new vhosts path for all existing and newly created domains.
Last edited by a moderator: