I fixed the problem with Virtual Host

Problems with the Windows version of XAMPP, questions, comments, and anything related.

I fixed the problem with Virtual Host

Postby productive1 » 18. May 2005 08:46

For the people out there That are haveing problems with Virtual host and want to host multiple domain names follow theses instuctions:
I only tried this with Windows XP home and it worked for me good.

Ok first in the httpd.conf file go to the bottom of the page and Where you will see this

# Use name-based virtual hosting.
#
#NameVirtualHost *
#
#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.

1)Ok know that you see it you will have to take away the (#) from NameVirtualHost *

2) add :80 to NameVirtualHost * (so now it should like this ) NameVirtualHost *:80

3) In the bottom of the example that they give you, type:

<VirtualHost *:80>
ServerName localhost
DocumentRoot G:\apachefriends\xampp\htdocs
</VirtualHost>

(Make sure that you delete the (#) sign starting from
<VirtualHost *:80> to </VirtualHost>

4) type:

<VirtualHost *:80>
ServerName www.yourdomainname.com
DocumentRoot G:\apachefriends\xampp\htdocs\sites
</VirtualHost>

(Also make sure that you delete the (#) from there also and that there is a space between the first Virtual host and the second virtual host.

So now you will have this:

NameVirtualHost *:80
#
# 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>
ServerName localhost
DocumentRoot G:\apachefriends\xampp\htdocs
</VirtualHost>

<VirtualHost *:80>
ServerName www.yourdomainname.com
DocumentRoot G:\apachefriends\xampp\htdocs\sites
</VirtualHost>
#

5) this gets a little tricky but you will get it:

Now go to C:\WINDOWS\system32\drivers\etc and open the host file thats in there.

6) at the bottom of that file you will see:
127.0.0.1 localhost

(type in the bottom of that:

127.0.0.1 www.yourdomainname.com

So now it should look like this:

127.0.0.1 localhost
127.0.0.1 www.yourdomainname.com

Now save and close.

your done!

Remeber with www.yourdomainname.com put the domain name that you want to add as a second site and it should match the one that you put in the httpd.conf file and the line that you added in the host file. Also make sure that you make a new folder in your htdocs for your second domain name I ussually name it site2 and on...

Good luck! :D

any question just post
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby productive1 » 18. May 2005 19:28

This is how my virtual Host is in the httpd.conf file:



Image



And this is how my host file in C:\WINDOWS\system32\drivers\etc is

Image

Please remember this worked out beutiful for me in Windows Xp home service pack1. I do not know for other systems.

good luck! :D
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby jami » 23. May 2005 09:48

Hi,

I have the same problem and found your thread which appears to be exactly what i'm looking for, thanks.

However, I have one question concerning point 5 below,

5) this gets a little tricky but you will get it:

Now go to C:\WINDOWS\system32\drivers\etc and open the host file thats in there.

I wasn't aware the the system files in WINDOWS would need to be changed. Can you send me the config changes you made to both apache and your Windows XP SP1 system, as it appears that they weren't posted on the forum correctly. This way I can see the exact path in the WINDOWS file and the exact changes you made there.

I appreciate all your help
jami
 
Posts: 9
Joined: 08. April 2005 08:07

Postby productive1 » 23. May 2005 11:19

the file should be in : C:\WINDOWS\system32\drivers\etc
its called ( host ) click on it then its going to tell you "windows cannot open this file". Pick the botton that say " Select the program from a list" and choose notepad.

Thats it. :D
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby sckoh » 23. May 2005 15:19

Hello, gentlemen,
I used virtual host before when I had multiple domains but now use only one domain, without virtual host.
Therefore, my site may be same with or without virtual host.
Could you explain if I am right or wrong.

Code: Select all
DocumentRoot "D:/xampp/htdocs/home"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "D:/xampp/htdocs/home">
    Options Indexes FollowSymLinks MultiViews Includes ExecCGI
   AddType text/html .shtml
        AddHandler server-parsed .shtml
        AddHandler cgi-script .cgi .pl
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Therefore, in my case, my site is same whether I set virtual host or not.
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC

Postby productive1 » 23. May 2005 18:04

Thats because you are just running thru localhost, you really dont need to put that information in the virtualhost section. Now if you want multiples then I advise you to put localhost + second domain in the virtualhost section

Did that answer your quest?

thanks
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby sckoh » 23. May 2005 23:02

Thank you very much for explanation but I can't understand it completely
even though I set up again accroding to yours above.
I didn't feel any change.
Now I'm thinking what a doctor said to me before that my head is not so good.

I understood that virtualhost is required for multiple domains only.
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC

Postby productive1 » 23. May 2005 23:16

your not going to feal no difference if you just going to run 1 site( your site from localhost), you dont even need to put the localhost in the virtualhost part unless you are going to add another site to your computer. Now you will see the difference when you add another site, and put it in virtualhost becase you can go to localhost and you can go to yourdomainname.com and so on...

thanks :D
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby sckoh » 26. May 2005 10:14

Okay, productive1.
I understood your explannation that using 1 domain is same and no difference between virtual and actual.

By the way, my toppage has a $REMOTE_ADDRESS source to check visitor's IP and,
When I connect my toppage(PWS) with my domain from my computor, it displayed 211.234.243.174, under non-virtual configuration.
But when I try under virtual configuration, it gives 127.0.0.1.

Why is it different?
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC

Postby productive1 » 26. May 2005 18:43

sckoh wrote:Okay, productive1.
I understood your explannation that using 1 domain is same and no difference between virtual and actual.

By the way, my toppage has a $REMOTE_ADDRESS source to check visitor's IP and,
When I connect my toppage(PWS) with my domain from my computor, it displayed 211.234.243.174, under non-virtual configuration.
But when I try under virtual configuration, it gives 127.0.0.1.

Why is it different?


Well I would think that 211.234.243.174 is your computers main IP that was giving to you by you internet provider. To check go to www.showip.com if that number comes up then thats your computers ip. The 127.0.0.1 is your localhost running since you have apache installed. Just check with the above link to see if 211.234.243.174 is your computers main ip and let me know.

Thank You. :D
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby sckoh » 26. May 2005 23:53

Thank you, productive1.
My actual IP is 211.234.243.174.
I explained you that my IP's are different to each other when I load my computer into web as an actual server and virtual server.
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC

Postby productive1 » 27. May 2005 00:11

sckoh wrote:Thank you, productive1.
My actual IP is 211.234.243.174.
I explained you that my IP's are different to each other when I load my computer into web as an actual server and virtual server.


ok so what you are trying to tell me is that when you go in the internet that you have 2 ip, 1 for web surffing and 1 for your server at the same time?

Thanks :D
productive1
 
Posts: 12
Joined: 16. May 2005 08:07
Location: US, NY

Postby sckoh » 27. May 2005 08:17

HAHAHAHAHA...
I just wanted to know about virtual server.
Anyway, after I changed to virtual server, my machine's IP is always 127.0.0.1.

By the way, can you give me copy of mercury.ini for my reference?
I have differculties in setting mailserver.
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC

Postby ilustrate » 11. June 2005 22:07

productive1 wrote:This is how my virtual Host is in the httpd.conf file:



Image



And this is how my host file in C:\WINDOWS\system32\drivers\etc is

Image

Please remember this worked out beutiful for me in Windows Xp home service pack1. I do not know for other systems.

good luck! :D
Where do I find the httpd.conf file?
ilustrate
 
Posts: 8
Joined: 11. June 2005 03:47

Postby ilustrate » 13. June 2005 20:05

jami wrote:Hi,

I have the same problem and found your thread which appears to be exactly what i'm looking for, thanks.

However, I have one question concerning point 5 below,

5) this gets a little tricky but you will get it:

Now go to C:\WINDOWS\system32\drivers\etc and open the host file thats in there.

I wasn't aware the the system files in WINDOWS would need to be changed. Can you send me the config changes you made to both apache and your Windows XP SP1 system, as it appears that they weren't posted on the forum correctly. This way I can see the exact path in the WINDOWS file and the exact changes you made there.

I appreciate all your help
I am also curious as to why this needs to be made in WINDOWS. I thought this was also only supposed to be done in apache.
ilustrate
 
Posts: 8
Joined: 11. June 2005 03:47

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 138 guests