Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Don't understand something about virtualhosts
#1

I'm trying to get virtual hosts working on Apache.

 

In /etc/httpd/conf/http.conf it says that: DocumentRoot "/var/www/html". So I think that's the place where Apache will be looking for your website files.

 

I made a virtualhost:

 

NameVirtualHost ipadress:80

 

# Custom virtualhosts

 

<virtualhost ipadress:80></virtualhost>

ServerAlias www.feedmebits.nl

ServerAdmin maarten@feedmebits.nl

DocumentRoot feedmebits.nl

ServerName feedmebits.nl

ErrorLog logs/feedmebits.nl-error_log

#CustomLog logs/host.some_domain.com-access_log common



 

in /var/www/html/ I made two directories so it looks like this:

/var/www/html/websites/feedmebits.nl

 

 

When I restart Apached it restarts but gives me an error:

Starting httpd: Warning: DocumentRoot [/etc/httpd/feedmebits.nl] does not exist

 

When I try and make a directory in /etc/httpd/feedmebits.nl and restart apache I don't get the error message.

And when I try making putting feedmebits.nl in a sub directory: /etc/httpd/websites/feedmebits.nl I also get

an the same error message.

I don't quite understand this because isn't it supposed to go to DocumentRoot which is /var/www/html and if I added

directories in there and mentioned it in my virtual host, isn't it supposed to see it? Why am I getting an error?

Don't quite understand?

 

Another thing I noticed, is that when I have my virtualhost enabled, and try to go to my test.php which is in /var/www/html/test.php

It doesn't work anymore either. When I add it to /etc/httpd/feedmebits.nl, it works again.

Reply
#2

Something I discovered if I change the DocumentRoot it works.

 

# Custom virtualhosts

 

<virtualhost ipadress:80></virtualhost>

ServerAlias www.feedmebits.nl

ServerAdmin maarten@feedmebits.nl

DocumentRoot feedmebits.nl

ServerName feedmebits.nl

ErrorLog logs/feedmebits.nl-error_log

#CustomLog logs/host.some_domain.com-access_log common



 

DocumentRoot /var/www/html/websites/feedmebits.nl

 

 

I discovered in the /etc/http/conf/httpd.conf file that /etc/httpd is the serverroot directory path.

So I probably shouldn't put any website/data/directories there.

 

ServerRoot "/etc/httpd"

 

 

So I'm still trying to understand why in my virtualhost Document Root I have to

give the full path /var/www/html/websites/feedmebits.nl instead of just /websites/feedmebits.nl

because DocumentRoot is set to DocumentRoot "/var/www/html" in http.conf?

Reply
#3

Quote:Something I discovered if I change the DocumentRoot it works.

 

# Custom virtualhosts

 

<virtualhost ipadress:80></virtualhost>

ServerAlias www.feedmebits.nl

ServerAdmin maarten@feedmebits.nl

DocumentRoot feedmebits.nl

ServerName feedmebits.nl

ErrorLog logs/feedmebits.nl-error_log

#CustomLog logs/host.some_domain.com-access_log common



 

DocumentRoot /var/www/html/websites/feedmebits.nl

 

 

I discovered in the /etc/http/conf/httpd.conf file that /etc/httpd is the serverroot directory path.

So I probably shouldn't put any website/data/directories there.

 

ServerRoot "/etc/httpd"

 

 

So I'm still trying to understand why in my virtualhost Document Root I have to

give the full path /var/www/html/websites/feedmebits.nl instead of just /websites/feedmebits.nl

because DocumentRoot is set to DocumentRoot "/var/www/html" in http.conf?
 

 

Well I left it like that for now giving the full DocumentRoot for the virtualhost and it's working

Reply
#4
I realise you've already answered your own question here, but I wanted to just chime in that my Apache virtual hosts configuration has the full paths for the DocumentRoot declarations. Glad your virtual hosts are working.
Reply
#5

Quote:I realise you've already answered your own question here, but I wanted to just chime in that my Apache virtual hosts configuration has the full paths for the DocumentRoot declarations. Glad your virtual hosts are working.
 

Thanks for your reply. Been playing around with apache and trying out different things. It's been a while, glad you are back :)

Reply
#6

Quote:Thanks for your reply. Been playing around with apache and trying out different things. It's been a while, glad you are back
 

Yeah, I've been really really busy working on a project for a couple of weeks and haven't had the time to catch up here!

Reply
#7

ServerRoot should be mentioned ONCE in the main httpd.conf file and is the root dir for which all relative paths originate from.

 

If you have the following:



Code:
ServerRoot /etc/httpd
DocumentRoot mysite




Then Apache looks for /etc/httpd/mysite for your "index.html" file.

 

When configuring Vhosts, it's safer to use absolute paths for the DocumentRoot and logfile locations.

 

nb: Your ServerName *should* come before the ServerAlias, since ServerName is what the site is primarily known as. ServerAlias are alternative names.

Reply
#8

Quote:ServerRoot should be mentioned ONCE in the main httpd.conf file and is the root dir for which all relative paths originate from.

 

If you have the following:



Code:
ServerRoot /etc/httpd
DocumentRoot mysite

<div>


Then Apache looks for /etc/httpd/mysite for your "index.html" file.

 

When configuring Vhosts, it's safer to use absolute paths for the DocumentRoot and logfile locations.

 

nb: Your ServerName *should* come before the ServerAlias, since ServerName is what the site is primarily known as. ServerAlias are alternative names.



</div>
 

I changed my DocumentRoot to /home/feedmebits/www

I have my ServerName before my ServerAlias now

And I put feedmebits.net as another alias now and I restarted apache.

 

And I changed my config file to:

 



 

 

<virtualhost myip:80></virtualhost>

ServerName feedmebits.com

ServerAlias feedmebits.nl feedmebits.com feedmebits.net feedmebits.testing

ServerAdmin maarten@feedmebits.nl

DocumentRoot /home/feedmebits/www/feedmebits.nl

ErrorLog /var/log/httpd/websites/feedmebits.nl/error.log

CustomLog /var/log/httpd/websites/feedmebits.nl/access.log combined

 

<directory></directory>

AllowOverride None

order allow,deny

allow from all

Options Indexes Includes FollowSymLinks





I still get forbidden for feedmebits.com and I get the same for feedmebits.net now so that part works now :)

Reply
#9

Quote:ServerRoot should be mentioned ONCE in the main httpd.conf file and is the root dir for which all relative paths originate from.

 

If you have the following:



Code:
ServerRoot /etc/httpd
DocumentRoot mysite

<div>


Then Apache looks for /etc/httpd/mysite for your "index.html" file.

 

When configuring Vhosts, it's safer to use absolute paths for the DocumentRoot and logfile locations.

 

nb: Your ServerName *should* come before the ServerAlias, since ServerName is what the site is primarily known as. ServerAlias are alternative names.



</div>
 

I got everything except my index.html file. I tried change the ServerRoot file but I get an error. Going to try out some more things to see what happens.

Reply
#10

nooo! ServerRoot is the directory that is prepended to all RELATIVE paths - if you change that, you'll have to go through and change all your paths to modules, includes, external configs, etc. Best leave that part alone!

 

It *does* look like you're missing a "DirectoryIndex" directive in your <directory> container that points to your index page - may want to pop that in:</directory>

 



Code:
<Directory /home/feedmebits/www/feedmebits.nl/>
AllowOverride None
order allow,deny
allow from all
Options Indexes Includes FollowSymLinks
DirectoryIndex index.html
</Directory>




Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)