homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

do my sites have to be under the DocumentRoot?

 3:11 am on Jan 9, 2011 (gmt 0)

As I set up my new server, I've created a user home directory: /home/me/sites/

under that I've created folders for each of my sites:

and in each of those, a public_html folder to hold their stuff:

And in there, I've put a little index.php action.

Now, I've created my first VirtualHost entry:

NameVirtualHost *

<VirtualHost *>
ServerAdmin webmaster@domain1.com
DocumentRoot /home/me/sites/domain1.com/public_html
ServerAlias domain1.com *.domain1.com

The DNS for the domain is already set up properly

now when I point a browser at domain1.com, I see this:
You don't have permission to access / on this server.

instead, if I change my VirtualHost to point to this:
DocumentRoot /var/www/html/

then I see the PHP page I dropped there while I was setting up Apache.

So my question is: do my Virtual Host sites all need to be in a directory beneath the DocumentRoot specified in httpd.conf? (/var/www/html/)

If so, then I have a lot of reorganizing to do :(

I thought I was being smart by putting my sites into distinct folders.
On my previous host (using add-on domains in CPANEL) I was often annoyed that my sites were often accessible via subfolders and subdomains of the root domain, like
and I had to do some tedious shenanigans with .htaccess to prevent that

most of the other servers I've ever dealt with had that same configuration. Maybe I'm wrong for trying to reinvent the wheel?



 3:28 am on Jan 9, 2011 (gmt 0)

There's nothing wrong with your setup, just that you have probably not altered your httpd.conf to give Apache access to /home.

From memory (can't easily check the specifics at the time of posting), you will have have an entry for <Directory /> which will have a "Deny from all", then another for <Directory "/var/www/htdocs"> which will open things up a bit just for access to files within the specified document root. You just need to add a similar entry for your paths.

Alternatively you can separate out sites with one Unix login per site and use UserDir public_html (old-skool shared hosting style), then set the Virtual Hosts accordingly:


cPanel is evil. I hate nesting document roots, even for subdomains - there's no reason to do so.


 4:10 am on Jan 9, 2011 (gmt 0)

wicked. I'll pick through the conf looking for that

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved