Change the document root for a domain

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:

  1. Login to the Control Panel
  2. Select the service and domain that you would like to change the document root
  3. Click on “Web Hosting”
  4. At the right of the domain name, there will be a cog icon — click on in then on “Settings”
  5. Replace the document root with the new path

Your changes will be applied instantly.

An example

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.