Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have Apache web server installed on local Windows 7 x64 machine. It has no global DNS name.

In default distribution it has virtual host configured in Apache/conf/extra/httpd-vhosts.conf file.

It has one directive

NameVirtualHost *:80

and multiple directives

<VirtualHost *:80>

with different

ServerName www.domain.tld

Different names are written in hosts file and all pointing to 127.0.0.1.

Unfortunately, virtual hosts do not work. Only first <VirtualHost> tag seems to be active. Nothing said on httpd.exe starting and in error.log.

How to make virtual hosts working here?

EDIT

I see no reason why DNS can be required. GET request contains symbolic name of the site, so, the server has all information to distinguish which virtual host was called.

EDIT 1

I found that virtual hosts DO work (without DNS!). It is a problem with one specific host.

share|improve this question
    
The reason that DNS is normally used is that that is what most web browsers USE to set the Host: header. HTTP/1.1 requires the right Host: header to talk to virtual hosted websites. That said, you are free to put anything you like into a local hosts file. –  adaptr Feb 17 '12 at 11:28

1 Answer 1

up vote 1 down vote accepted

Virtualhosts are configured in the following file : extra/httpd-vhosts.conf

Here is an example on how to configure a Virtual Host

<VirtualHost *:80>
ServerAdmin webmaster@website.com
DocumentRoot "/var/sites/website"
<Directory "/var/sites/website">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny   
    Allow from all
</Directory>

ServerName www.website.com
#ServerAlias www1.website.com
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>

Remember to :

Configure your Normal and Aliasses names on your DNS manager, and remember to include this file on the httpd.conf main directives.

Include conf/extra/httpd-vhosts.conf

share|improve this answer
    
Sorry, what is DNS manager? I have no DNS name on a computer as I said. –  Suzan Cioc Feb 16 '12 at 20:23
    
After that, restart the server httpd -k restart –  GersonO Feb 16 '12 at 20:24
    
Sorry I don't understand what to do. All you said was already done at my computer except DNS. –  Suzan Cioc Feb 16 '12 at 20:28
    
Add the <virtualHost> tags as I mentioned on your httpd/conf/extra/httpd-vhosts.conf file, and make it fit to your servers name (The same name you configure on the dns otherwise it wont work) –  GersonO Feb 16 '12 at 21:28
    
I have no DNS, as I said. I am controlling access with hosts file. See no reason why it can't work with hosts. –  Suzan Cioc Feb 17 '12 at 10:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.