Forum Moderators: phranque

Message Too Old, No Replies

Virtualhost Problems

         

anthrt

7:32 pm on Sep 18, 2005 (gmt 0)

10+ Year Member



im trying to set up virtualhosts on a server of mine. now, i run /usr/sbin/httpd -S to test the config, it says everything is fine. however, when i try 'service httpd start' it fails. replacing the httpd.conf file with the original works fine. this is the syntax of the virtualhosts section:


#
# 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>


(yes i have changed ipaddresshere.. i just removed it, also domain.com is changed)

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.

AranhaHunter

9:34 pm on Sep 18, 2005 (gmt 0)

10+ Year Member



If you want to access your local site on domain.com you have to change the hosts file on windows/system32/drivers/etc/

Of course I'm assuming you are using a Windows OS

anthrt

9:38 pm on Sep 18, 2005 (gmt 0)

10+ Year Member



fedora core 4. i guess is hould have mentioned that initially. anyway, i assume the same principle applies for linux?

AranhaHunter

3:26 am on Sep 19, 2005 (gmt 0)

10+ Year Member



I believe so, though I wouldn't be 100% sure of that. Try it and let us know how it goes.

anthrt

9:43 am on Sep 19, 2005 (gmt 0)

10+ Year Member



well it didnt work, i added the following line to the hosts file:

ipaddresshere domain.com

httpd still fails to start.

AranhaHunter

11:43 am on Sep 19, 2005 (gmt 0)

10+ Year Member



mmmmm I dont know.

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

Romeo

12:21 pm on Sep 19, 2005 (gmt 0)

10+ Year Member



Hi Anthrt,

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.

anthrt

12:36 pm on Sep 19, 2005 (gmt 0)

10+ Year Member



ok something appears to be working now.

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.