XAMPP & Virtual Hosts

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

XAMPP & Virtual Hosts

Postby ApacheBear » 09. February 2005 09:13

I installed XAMPP about six months ago and learned how to create virtual hosts. If I remember correctly, the folder apache > htdocs is supposed to be in the same folder as your websites, but I wanted to keep XAMPP and my websites in separate locations...

C:\xampp\
C:\sites\

...so I copied htdocs and pasted it inside C:\sites\

It worked great; I could create my websites at http://mysite/ The only problem was that I could no longer access XAMPP's home page at http://localhost/ However, I figured out a new URL to access the page.

About a week ago, my computer crashed, and I'm now reinstalling all my software and trying to reconfigure virtual hosts. I downloaded the latest version of XAMPP (great job!). I still have a copy of my original apache > conf file, so I copied my virtual host settings and pasted them into my new conf file. Then I restarted my computer and pasted a copy of htdocs into C:\sites\

It's sort of working; I can preview my websites at http://localhost/geobop/, etc. However, I want to preview them at http:/geobop/

One other twist is that xampp is no longer at C:\xampp\

It's now at C:\apachefriends\xampp\ (I tried installing XAMPP to C:\xampp\, but it wouldn't work.

Before this gets even more confusing, let me summarize what I'd like eto do:

1. Keep my websites at C:\sites\

2. Keep XAMPP at C:\apachefriends\xampp\ (Or C:\xampp\, which would be even better)

3. Be able to preview my websites at http://mysite/

4. Stll be able to access XAMPP at http://localhost/

Can I do all of these, or do I have to make some compromises? If it's doable, how can I do it?

Thank you.
ApacheBear
 
Posts: 5
Joined: 06. February 2005 03:49
Location: Seattle

Postby webmosher » 09. February 2005 20:00

Well, unless the Internet has changed sigificantly, I will have some trouble seeing your localhost from this machine. :D

All kidding aside, there is another way you can try to do this that might be a bit more efficient than copying files around. Add the following to the bottom of your httpd.conf:

Code: Select all
NameVirtualHost *:80

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

<VirtualHost *:80>
ServerName www.mysite.com
ServerAlias mysite.com *.mysite.com
DocumentRoot c:\sites\mysite.com
</VirtualHost>


Note how you don't have to move your XAMPP htdocs and you can create a document root separate from XAMPP. If you start hosting lots of domains, you can get even fancier. Info on this is available below:
http://httpd.apache.org/docs-2.0/vhosts/mass.html

Hope this helps...
webmosher
 
Posts: 7
Joined: 08. February 2005 15:01

Postby ApacheBear » 09. February 2005 20:49

Ah, thanks for the tip. I think I understand it, and I've already had partial success in implementing it. Specifically, http://localhost/ doesn't flake out; I can still access XAMPP's home page there.

Unfortunately, I can't preview my website, but I probably just made an obvious mistake. I replaced your full URL's - www.mysite.com - with "geozoo," the name of one of my sites. I'm setting up virtual hosts for my LOCAL sites, on my computer. Once they're published online, my webhost takes care of everything else. So this is what I wound up with:

NameVirtualHost *:80

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

<VirtualHost *:80>
ServerName geozoo
ServerAlias geozoo *.geozoo
DocumentRoot c:\sites\geozoo
</VirtualHost>

But when I type http://geozoo/ into my browser, nothing happens. (Actually, it links to one of my online sites, http://www.geobop.com/mammals/, for some odd reason.) Can you see what I'm doing wrong?

Also, is this stuff case sensitive? For example, if I changed C:/sites/geozoo to C:/sites/GeoZoo, would I have to change the above script?

Thanks.
ApacheBear
 
Posts: 5
Joined: 06. February 2005 03:49
Location: Seattle

Postby ApacheBear » 09. February 2005 21:02

Nevermind...

I was just reminded about the secret ingredient, modifying WINDOWS > Systems32 > Drivers > Etc > Hosts

Using your tip, I can now preview my websites at http://mysite/ AND access XAMPP central at http://localhost/

It's even better than my original configuration. :)

Thanks.
ApacheBear
 
Posts: 5
Joined: 06. February 2005 03:49
Location: Seattle

Postby jchapel » 09. February 2005 21:07

Your first Virtualhost directive needs to include the same ServerName and DocumentRoot as your main server.

In other words your first VirtualHost needs to define your main server.
J Chapel
The application server in my pocket runs on XAMPP
XAMPP Demo http://xampp.no-ip.info
ZPANEL Demo http://zpanel.no-ip.info
jchapel
 
Posts: 25
Joined: 15. January 2005 09:32

Postby portrower8 » 10. February 2005 05:14

okay,

I am trying to set this up in xampp...but I don't see it working. I added the following to the bottom of httpd.conf located:
c:\webserver\xampp\apache\conf\httpd.conf

at the very bottom I put:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot c:\webserver\xampp\htdocs\tndatabase
</VirtualHost>

<VirtualHost *:80>
ServerName www.website1.com
ServerAlias website1.com *.website1.com
DocumentRoot c:\webserver\xampp\htdocs\tndatabase
</VirtualHost>

<VirtualHost *:80>
ServerName www.website2.com
ServerAlias website2.com *.website2.com
DocumentRoot c:\webserver\xampp\htdocs\website2
</VirtualHost>


for example, on the localhost entry, one would think tndatabase contents would show -- but they don't. xampp main entry page still does.


I am clearly not understanding something...please help!
portrower8
 
Posts: 4
Joined: 08. February 2005 03:45

Postby davedenis » 10. February 2005 19:02

I'm having a similar problem and I have practically the same files. My hosts file:

127.0.0.1 localhost
127.0.0.1 fcf

my httpd.conf:

NameVirtualHost 127.0.0.1

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

<VirtualHost *:80>
ServerName fcf
ServerAlias fcf *.fcf
DocumentRoot c:\www\fcf
</VirtualHost>

But when I go to http://fcf/ I always get redirected to the localhost xampp splash page. Any ideas?
davedenis
 
Posts: 4
Joined: 08. February 2005 21:49

Postby portrower8 » 10. February 2005 19:26

well, you know I don't but if you find out surely post it here and let me know. I'll be hunting for the answer too. If I find it I'll also post here.
portrower8
 
Posts: 4
Joined: 08. February 2005 03:45


Return to XAMPP for Windows

Who is online

Users browsing this forum: Altrea and 132 guests