Forum Moderators: phranque

Message Too Old, No Replies

Virtual Host Problem

         

burrows1980

5:00 pm on Dec 31, 2007 (gmt 0)

10+ Year Member



Hi,

Thank god in finding this forum! Im very new to servers!

I trying to set up virtual host for one IP address.

Ive installed Apache 2.2.6 no_ssl

Checked in my browser http://localhost and all works fine.

Currently in httpd.conf file i have:

Serveradmin [my email]
ServerName www.example.com:80
DocumentRoot "C:/www/docs"
<Directory "C:/www/docs">
#Listen 12.34.56.78:80
Listen 80

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

To get virtual host to work I take it i remove the # before, include line, and edit the httpd-vhosts.conf?

Currently when I goto localhost in browser it shows:

Index of /
example/
quux-foo/

My two sites in C:/www/docs, click which one you want.

This is where I become a bit thick and not really sure what it means, ive read so many different sites and the apache instructions but dont fully understand what I need to do!

In the httpd-vhosts.conf, i need to delete the dummy-host bit? if I leave the two log lines in I get a error message when restarting it, delete the lines no error message.

After restarting Apache, and goto localhost it only displays my example.com site. Do I need to change anything in the httpd.conf such as document root etc because of using virtual server?

NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/www/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log common"
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.quux-foo.co.uk
DocumentRoot "/www/docs/dummy-host2.quux-foo.co.uk"
ServerName dummy-host2.quux-foo.co.uk
ErrorLog "logs/dummy-host2.quux-foo.co.uk-error_log"
CustomLog "logs/dummy-host2.quux-foo.co.uk-access_log common"
</VirtualHost>

Thats before I make any changes, this is after:

<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/www/docs/example"
ServerName example.com
ServerAlias www.example.com
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@quux-foo.co.uk
DocumentRoot "/www/docs/quux-foo"
ServerName quux-foo.co.uk
ServerAlias www.quux-foo.co.uk
</VirtualHost>

Hope someone can help me, hopefully its something simply, been trying this for over a day now and not getting anywhere quick!

Just in case its of help, im using:

Windows Server 2003
Apache 2.2.6 no_ssl
Zone Edit for my DNS
ISP - SKY Broadband
Router/modem - Netgear DG834GT

Thanks in advance

Gareth

[edited by: jdMorgan at 8:05 pm (utc) on Dec. 31, 2007]
[edit reason] examplified domains - Please see Terms of Service [/edit]

burrows1980

5:10 pm on Dec 31, 2007 (gmt 0)

10+ Year Member



Err, after a day and a bit of scratching my head, its working!

Not sure why it wasnt before but both r working on the web, cant get it to work in localhost but not fussed about that really!

If I try to connect to a domain of mine on one of my networked pc's it takes me to my router setup page? so I have to try it on good old dial up to see if its working!

Will try and sort that one day when I understand what to do.

Will look forward to using this site more now Ive found it.

Regards,

Gareth

jdMorgan

8:13 pm on Dec 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For use on your local network, you will need to define the DNS for all local machines unless you are also running a local DNS server.

The most common way to do this is to open the "hosts" file on each computer and add entries for the domain names you want to resolve locally. The name of the file is just 'hosts' --no file extension-- and it is a plain-text file. On WinXP, a typical location is C:\windows\system32\drivers\etc

On the server machine, it might be:
127.0.0.1 localhost
127.0.0.1 example.com
127.0.0.1 www.example.com
127.0.0.1 quux-foo.com
127.0.0.1 www.quux-foo.com

and on all of the other local network machines:
127.0.0.1 localhost
192.168.0.4 example.com
192.168.0.4 www.example.com
192.168.0.4 quux-foo.com
192.168.0.4 www.quux-foo.com

Note that you must define each subdomain separately. Replace 192.168.0.4 with the LAN IP address of your server.

Jim

burrows1980

1:03 pm on Jan 1, 2008 (gmt 0)

10+ Year Member



Hi Jim,

Thanks for that, works fine now!

Can get my sites sorted now.

Gareth