(dv):Change document root or httpdocs directory
- This page was last modified on July 6, 2011, at 12:57.
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.
Instructions
- 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.
-
Log into your (dv) Dedicated-Virtual Server as root with SSH and change to the following directory:
cd /var/www/vhosts/example.com/conf/ -
Create your local Apache configuration file using vim:
vim vhost.conf
-
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/mywebRemember 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.
- Using the websrvmng command, reload your Apache configuration:
/usr/local/psa/admin/sbin/websrvmng -av
-
Restart Apache gracefully:
/etc/init.d/httpd graceful
-
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.