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:
/home/me/sites/domain1.com
/home/me/sites/domain2.com
/home/me/sites/domain3.com
/home/me/sites/domain4.com
and in each of those, a public_html folder to hold their stuff:
/home/me/sites/domain4.com/public_html
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
</VirtualHost>
The DNS for the domain is already set up properly
now when I point a browser at domain1.com, I see this:
Forbidden
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
ht
tp://mypersonaldomain.com/anothersite/index.php
and
ht
tp://anothersite.mypersonaldomain.com/index.php
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?