Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DocumentRoot takes one Argument

Status
Not open for further replies.

ThinkGeekness

Technical User
Jan 20, 2003
55
US
I have Apache 1.3 and I am setting up name based virtual hosting and so far it looks like this:

ServerName domain.com
DocumentRoot /home/httpd/domain
BindAddress *

NameVirtualHost *

<VirtualHost *>
ServerName domain.com
DocumentRoot /home/httpd/domain
</VirtualHost>
<VirtualHost *>
ServerName domain2.com
DocumentRoot /home/httpd/domain2
</VirtualHost>

When I try to start apache, I get this error message:

DocumentRoot takes one Argument, Root directory of the document tree

How do I fix this?

Thanks
 
Update: I took out the DocumentRott from the firts virtual host, and I still get the same error message. The only way that I can get so that it actually starts, is if I take it out of the first and second virtual host, but then Apache doesnt know where to point the second virtual host.
 
Why do you have the first virtual host? It's the same as your server defaults. Just eliminate the first virtual host altogether - it's redundant. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
I need the first virtual host. But now it is working, it turns out I need the &quot; in front and end of the directory. Ex. DocumentRoot &quot;/home/httpd/domain&quot;. But now I have ran into a different problem. For an example, if I have an about us on domain2, it goes to the about us on the main domain. But it shows the address as: If I go to it goes to and the about us is the one for the main domain. If you have any questions about this or I didnt work it right, go ahead and ask. But any suggestions towards fixing this?
 
You don't need the first virtual host. That function is already covered by the defaults you set under:

ServerName domain.com
DocumentRoot /home/httpd/domain
BindAddress *

So domain2 is the only virtual host you need. You've set the first virtual host the same as the server default, which is redundant. You can delete the first virtual host entirely. When someone types your ServerName into the browser, it will go to domain.

Do you have &quot;UseCanonicalName Off&quot; set in the virtual hosts, but On for the default server config? That's how mine work.

# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a URL that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a &quot;canonical&quot; name. With this setting off, Apache will
# use the hostname:port that the client supplied, when possible. This
# also affects SERVER_NAME and SERVER_PORT in CGI scripts.

I believe that's what's steering you to the default server directory for the pages. Make sure you restart Apache after the changes. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
Thanks for your help. It turns out that I do need a first virtual host, or Apache will think that domain2 is the default domain. Also, UseCanonicalName Off did not work, I had to use UseCanonicalName On to get it to work. You helped guide me on the right topic though. Thank you.
 
Hi all,

If any virtualhosts are defined, the domain defined in the default is redundant.

So if you want 2 sites on the one server, you need to have 2 virtualhosts, adding 1 would only allow access to that site.

Hope this helps Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
??

I guess I don't understand that. I have a ServerName and the default directory for the docs, and 5 other virtual hosts. When I type the default domain into my browser, I get the default domain. When I type any others, I get the correct ones. Are you saying I need to create a virtual host for the default, and leave the default blank? The default domain is not in the virtual hosts, and all works well. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
I have UseCanonical Name On for the default server, and Off for all the virtual hosts. This works. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
Hi mate,

You should have the default domain specified in addition to the 5 others.

The following is quoted from the Apache docs:

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

For example, suppose that you are serving the domain and you wish to add the virtual host which points at the same IP address. Then you simply add the following to httpd.conf:

NameVirtualHost *

<VirtualHost *>
ServerName DocumentRoot / </VirtualHost>

<VirtualHost *>
ServerName DocumentRoot / </VirtualHost>


Hope this helps
Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top