Forum Moderators: phranque

Message Too Old, No Replies

Virtual Host Doesnt Host more than 6 Domain

         

Sakkarin

10:09 pm on Jun 11, 2004 (gmt 0)



I have a problem about apache virtual host
I am hosting 3 domain and 3 subdomain on apache but i cant add new domain into httpd.conf when i add apache service is not running
where can be the problem?
my httpd.conf is like this

NameVirtualHost www.example.gen.tr
<VirtualHost www.example.gen.tr>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example"
ServerName example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost www.example.org
<VirtualHost www.example.org>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example2"
ServerName example.org
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost www.examplescorp.com
<VirtualHost www.examplescorp.com>
ServerAdmin scorp@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/syldatabase"
ServerName examplescorp.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost kayit.example.gen.tr
<VirtualHost kayit.example.gen.tr>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/kayit"
ServerName kayit.example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost sifre.example.gen.tr
<VirtualHost sifre.example.gen.tr>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/pw"
ServerName sifre.example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

[edited by: jdMorgan at 10:34 pm (utc) on June 11, 2004]
[edit reason] Removed specifics per TOS [/edit]

gergoe

11:54 am on Jun 13, 2004 (gmt 0)

10+ Year Member



Sakkarin,

The only one attribute of the <VirtualHost> container is an ip address (or a wildcard character) and the port (if you leave it out it uses the value of the Port directive from your httpd.conf).
Virtual hosting can be implemented in three diferent ways:
Name based virtual hosting
Apache listens on all the specified ip and port combinations, and if a request comes through one of the ip/port combinations specified by the NameVirtualHost directive then it searches all the Virtualhost containers for a matching server name, and uses the one which is matched, or if there/s no match uses the first one which has the same ip and port specified as where the request is made through. In this scenario, your config looks like this:


NameVirtualHost *
<VirtualHost *>
ServerName www.domain1.com
DocumentRoot dev/null
</VirtualHost>
<VirtualHost *>
ServerName www.domain2.com
DocumentRoot dev/null
</VirtualHost>

IP or Port based virtual hosting
Apache listens on all the specified ip and port combinations, and if a request comes through an ip/port combination specified by one of the VirtualHost containers then it uses that one. If there's no match the "main" server is used from your httpd.conf. In this scenario, your config looks like this:

NameVirtualHost *
<VirtualHost 192.168.0.1>
DocumentRoot dev/null
</VirtualHost>
<VirtualHost 192.168.0.2>
DocumentRoot dev/null
</VirtualHost>
<VirtualHost 192.168.0.2:8080>
DocumentRoot dev/null
</VirtualHost>

You can mix these ways of implementing in several ways, I suggest you to read the [httpd.apache.org...] url for further details.

Unfortunately you did not posted your new virtual host which does not want to work, but I'll fixed the one you sent so you can try to add it again, an if it will not work come back with the faulty one.


NameVirtualHost [i]ip_address_pointing_to_the_server #1[/i]
...
NameVirtualHost [i]ip_address_pointing_to_the_server #n[/i]
<VirtualHost [i]ip_address_pointing_to_the_server #1[/i]>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example"
ServerName example.gen.tr
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #1[/i]>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example2"
ServerName example.org
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #2[/i]>
ServerAdmin scorp@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/syldatabase"
ServerName examplescorp.com
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #2[/i]>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/kayit"
ServerName kayit.example.gen.tr
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #3[/i]>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/pw"
ServerName sifre.example.gen.tr
</VirtualHost>

The <VirtualHost ...> must be always an ip address. If you use dns names instead, the Apache always have to do a dns lookup to obtain the ip address, but if for some reason the dns server is not available, the domain is not registered, the ip address is different than the ip addresses of your server then the Apache will not work! Apache uses the ServerName and the ServerAlias directives to check the hostname in a request against the virtual hosts.
The NameVirtualHost directive is used to tell Apache on which IP Addresses they do names based lookups for the virtual hosts, the same applies as for the pervious one, don't use hostnames. Additionally you need to specify each ip address only once, it does not have use to do it more than once.

Try to implement the same into your server config, and if you still get stuck, tell us more about your environment (number of ip addresses, and the ip addreses of each domains pointing to your server) and someone will help you with this.