homepage Welcome to WebmasterWorld Guest from 54.205.207.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
how to make a virtual host like http://mysite in Apache?
just need to review sites in local computer
mms19

10+ Year Member



 
Msg#: 418 posted 3:06 pm on Oct 18, 2003 (gmt 0)

I have Apache for Windows installed in my local computer. I have a few sites in different folders, say c:/my documents/web/mysite and d:/www/othersite.
I would like to access the sites directly via [mysite...] and [othersite....] So, I just set the VirtualHost in the httpd.conf as

NameVirtualHost mysite

<VirtualHost mysite>
ServerAdmin webmaster@example.com
DocumentRoot c:/my documents/web/mysite
ServerName mysite
</VirtualHost>

<VirtualHost othersite>
ServerAdmin webmaster@example.com
DocumentRoot d:/www/othersite
ServerName othersite
</VirtualHost>

but this does not work.

What did I do wrong? Anything need to be set particularly in Apache for Windows?

Thank you.

 

dmorison

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 418 posted 5:03 pm on Oct 18, 2003 (gmt 0)

Try using automatic virtual hosts instead; add the line...

VirtualDocumentRoot c:/my documents/web/%0

...to your Apache config; and then build your sites in sub-directories at c:/my documents/web/ with the directory name equal to the host name you wish to use. Apache will replace %0 in the above example with the host name in use and take that as the document root.

BjarneDM

10+ Year Member



 
Msg#: 418 posted 6:50 pm on Oct 18, 2003 (gmt 0)

does Windows have a hosts file?

the problem is, that your sites don't have dns records.

on all *nix platforms you modify the hosts file and enter lines for each of your virtual non-existing web-sites

DaveAtIFG

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 418 posted 7:05 pm on Oct 18, 2003 (gmt 0)

On Win2K at least, lmhosts is the *nix equivalent of hosts. Win2K help under "Configure TCP/IP to use WINS" details using lmhosts.

robho

10+ Year Member



 
Msg#: 418 posted 3:19 pm on Oct 21, 2003 (gmt 0)

You need both the Apache entries and DNS.

The file "hosts" (possibly in c:\windows\system\drivers\etc - varies by windows version) should have one entry for each site:

127.0.0.1 localhost
127.0.0.1 local.widgetdomain1.com
127.0.0.1 local.widgetdomain2.com
etc..

In my httpd.conf I just have (repeated for each site):
<VirtualHost *>
DocumentRoot /home/widgetdomain1.com/web
ServerName local.widgetdomain1.com
</VirtualHost>

The virtual host bit can have other directions for each site, such as rewrites, DirectoryIndex etc.

Restart Apache after changing the config, of course. Then the local version of each site is reachable with local.widgetdomain2.com etc., in place of www... for the live site.

(I should also mention that I think having them all at 127.0.0.1 didn't work for me in earlier Windows - I used 127.0.0.2, 3, etc. but seems OK in XP.)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved