(dv):Change document root or httpdocs directory

  • This page was last modified on July 6, 2011, at 12:57.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

Contents

Overview

The default document root, or web root directory, on your (dv) Dedicated-Virtual Server is /var/www/vhosts/example.com/httpdocs/. You can change this by modifying your local Apache configuration.

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Results

By following the instructions in this article, you will make the following changes to your server:

You can use any directory on the server as your document root. For example, your new document root could be /var/www/vhosts/example.com/myweb/ or /my/unique/webroot/.

You will be running Apache as CGI.

If you want to use a directory that is already inside httpdocs, such as /var/www/vhosts/example.com/httpdocs/home/, as your document root, you should consider a 301 Redirect instead, as a 301 Redirect is less invasive.

Instructions

Please replace example.com and domainuser in the examples with your own domain name and with the FTP user for that domain, respectively. This is the Plesk FTP user shown in the Setup section for each domain.
  1. Log into your Plesk control panel. Go to Domains, select your domain name, then Setup. Make sure PHP and CGI support are selected. Click OK to save your changes.
  2. Log into your (dv) Dedicated-Virtual Server as root with SSH and change to the following directory:
    
    cd /var/www/vhosts/example.com/conf/
    
  3. Create your local Apache configuration file using vim:
    vim vhost.conf
    
  4. Insert the following contents in your file and save:
    vhost.conf
    
    <Directory /var/www/vhosts/example.com/myweb>
    Options -Includes -ExecCGI
    </Directory>
    DocumentRoot /var/www/vhosts/example.com/myweb
    

    Remember that you can enter any valid path here as well, such as /my/unique/webroot/.

    vim tip: Type "i" to enter insert mode. Type or copy/paste desired text. Type "Esc" to exit insert mode, then ":wq" to save and quit.

  5. Using the websrvmng command, reload your Apache configuration:
    /usr/local/psa/admin/sbin/websrvmng -av
    
  6. Restart Apache gracefully:
    /etc/init.d/httpd graceful
    
  7. Use the chown command to ensure that your new document root, and any files within it, have the correct ownership. Remember to replace domainuser with your own FTP user for that domain. psaserv and psacln are the correct groups for Plesk.

    Please be careful to specify the correct directory when running a chown -r command, as this recursively affects all the files and directories inside the specified directory.

    
    chown domainuser:psaserv /var/www/vhosts/example.com/myweb
    chown -R domainuser:psacln /var/www/vhosts/example.com/myweb/*
    


That's it! You have now changed your document root, and should be able to view the contents of your new folder from your browser.

Supplements

If you are comfortable running Apache as CGI to make this change, you should consider running Apache as FastCGI, which can improve your website performance. See Running PHP as FastCGI on your (dv), resolving Apache permission errors, or read this forum thread for more information. Please visit this article for instructions on becoming a forum member.