Change the document root for a domain
Many times, you will need to change Apache’s default path where you need to store your files so they are displayed on your site (which is
/var/www/vhosts/yourdomain.com/httpdocs/). This is specially true for frameworks (like Symfony or Zend Framework) where you should only display the files inside a directory called “web” or “public”, while the other files reside “outside”.
This directory is called the “Document Root“, and it can be changed easily with our Control Panel.
To change your document root:
- Login to the Control Panel
- Select the service and domain that you would like to change the document root
- Click on “Web Hosting”
- At the right of the domain name, there will be a cog icon — click on in then on “Settings”
- Replace the document root with the new path
Your changes will be applied instantly.
Suppose you want to install Symfony, and the location in your server that those files are stored is
/var/www/vhosts/yourdomain.com/httpdocs/. Once you install Symfony, you should go to yourdomain.com/web so you can see the default page.
Since you need the Document Root to be
web/, you change the document root to
/var/www/vhosts/yourdomain.com/httpdocs/web/. Now, you should be able to access your site without the
/web/ prefix: yourdomain.com.