Forum Moderators: phranque
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
##
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#<VirtualHost *:80>
ServerAdmin root@localhost
DocumentRoot /var/www/html/
ServerName ipaddresshere
</VirtualHost><VirtualHost *:80>
DocumentRoot /var/www/domain.com/
ServerName domain.com
</VirtualHost>
anyway, thats the config, the 'ipaddresshere' has the ip address of the main server, or the main document root. the 2nd virtualhost block is one i want to go to /domain.com when domain.com is accessed, although it fails.
I'd try the following:
NameVirtualHost 111.1.1.10
NameVirtualHost 111.1.1.11
<VirtualHost 111.1.1.10>
ServerAdmin owner@whatever.whatever
DocumentRoot /var/www/html/
ServerName whatever.whatever
</VirtualHost>
<VirtualHost 111.1.1.11>
DocumentRoot /var/www/domain.com/
ServerName whatever.youwant
</VirtualHost>
then, i'd go to the host file and add it there
111.1.1.10 whatever.whatever
111.1.1.11 whatever.youwant
Of course you'd change that to your current ones.
That worked for me perfectly. I don't see why it wouldn't work on linux. If this doesn't work, try this link, it should give you a heads up:
[mezzoblue.com...]
Hopefully this will help you, somehow
welcome to WW.
... when i try 'service httpd start' it fails.
Can you, please, be more specific about what 'fails'.
The apache writes an error_log, where a lot can be learnt from about the specifics and further details of a failure.
The
"NameVirtualHost *:80"
is OK and sufficient. The * makes the httpd listen on all interfaces by default, including 127.0.0.1/localhost, so there is no need to explicitly specify IP-addresses, except in some special configurations where you may want to limit the apache to run on a specific interface only.
There is no need for the VirtualHost block with the
"ServerName ipaddresshere"
(which is used incorrectly here: it says "ServerName", not "ServerIPaddress").
Just cut the entire block, as the IP address is already included in the * of the NameVirtualHost statement above.
Regards,
R.
the virtualhosts appear to be working - slightly.
i have changed the dns servers of domain.com to the ones of the hosting company that provide the server. they have successfully changed. i have added domain.com to the hosts file. i have a virtualhosts entry for domain.com.
however, when i try to access domain.com or even www.domain.com, it does not resolve.