Subdomain with XAMPP

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

Subdomain with XAMPP

Postby bazianm » 19. February 2009 21:02

Hi,

I have two related situations. In both cases, I installed XAMPP on a windows machine. In one case, I installed it on a network server so I could have some web apps for my users and in another I installed it on a local machine so my son could test some web work.

In both cases, I need to create a subdomain. In one case I need to have sub.localhost and in another I need sub.servername.

I am looking for a walkthrough on how to do this.

Oh, and I am a relative newbie when it comes to apache...

Any assistance would be greatly appreciated...
bazianm
 
Posts: 10
Joined: 19. October 2006 22:40

Re: Subdomain with XAMPP

Postby Wiedmann » 19. February 2009 21:12

Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Subdomain with XAMPP

Postby bazianm » 19. February 2009 21:24

Thanks. I will try it out right now...
bazianm
 
Posts: 10
Joined: 19. October 2006 22:40

Re: Subdomain with XAMPP

Postby bazianm » 19. February 2009 22:45

OK, I tried it. I am most of the way there.

I am working on httpd-vhosts.conf. Here are the directives I have here...

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot "c:/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot "c:/xampp/htdocs/sugar"
ServerName sugar.localhost
ServerAlias sugar.menachemxp-virt
</VirtualHost>

When I work from the local machine, it works great. http://localhost/ takes me to the xampp page. sugar.localhost takes me to my app (I added sugar.localhost to the windows\system32\drivers\etc\hosts file.

For the record, the name of the machine is menachemxp-virt

On another machine, I added sugar.menachemxp-virt to the hosts file there. When I go to http://sugar.menachemxp-virt it takes me to the xampp page, not to the subdomain.

What am I missing??

Thanks for your help,

Menachem
bazianm
 
Posts: 10
Joined: 19. October 2006 22:40

Re: Subdomain with XAMPP

Postby dmphotography » 20. February 2009 01:28

Hey bazianm,
The problem is with your second VirtualHost entry. You cannot specify a different ServerName and ServerAlias in the same VirtualHost.
The ServerName and ServerAlias should be the same more less. Here's an example of how to use it correctly:

<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot "c:/xampp/htdocs/sugar"
ServerName sugar.localhost
ServerAlias www.sugar.localhost
</VirtualHost>

And if you want sugar.menachemxp-virt as a VirtualHost, you simply add another VirtualHost for it like so:

<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot "c:/xampp/htdocs/sugar"
ServerName sugar.menachemxp-virt
ServerAlias www.sugar.menachemxp-virt
</VirtualHost>

If you are using HOSTS file entries, the ServerAlias directive isn't necessary. It's used for public domain names.

As a side note, the reason you're reaching the XAMPP page is because when Apache cannot correctly identify a domain name in the VirtualHost file, it will automatically send the incoming traffic to the first VirtualHost entry, which you have listed as your localhost entry.

That should fix your problem though.
For great video and written tutorials and guides on creating your own web server and installing things such as forums, blogs, etc., visit http://myownhomeserver.com
dmphotography
 
Posts: 191
Joined: 15. December 2008 14:25
Location: Columbus, MS
Operating System: Windows 7

Re: Subdomain with XAMPP

Postby Wiedmann » 20. February 2009 09:09

You cannot specify a different ServerName and ServerAlias in the same VirtualHost.

Sure, that's the reason for ServerAlias: To can use any other hostname for this vhost too.

(Well, most time it's used to have www.foo and foo for the same vhost. But technically, www.foo and foo are completely different hostnames and can also live on different servers.)

The ServerName and ServerAlias should be the same more less.

A software (Apache) is not a human reader ;-) For it, the difference between "www.foo" and "foo" or "foo" and "bar" is the same.

If you are using HOSTS file entries, the ServerAlias directive isn't necessary.

That's also wrong:
First a web browser must know the IP for a hostname, so it can connect to the web server. And it can know this from a dns server or a hosts file. If the browser connect to the server (with using the ip), it also send a header with the hostname it want to access.

For namebased vhosts:
And now the server compares this header value with the values from Servername/ServerAlias. If the server found a match, it delivers from this vhost. It the server don't find a match, it delivers from the first (default) vhost.


OK, back to topic, and that's the problem... the vhost.conf should work in the way the thread starter want.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Subdomain with XAMPP

Postby Ginno » 25. February 2009 21:39

I have a problem
i have this domain thedreamers.idle.ro (configurated with my ip)
i have added in httpd-vhosts.cfg
Code: Select all
<VirtualHost *:80>
ServerName www.thedreamers.idle.ro
ServerAlias thedreamers.idle.ro
DocumentRoot C:\xampp\htdocs\www
</VirtualHost>


<VirtualHost *:80>
ServerName www.torrent.thedreamers.idle.ro
ServerAlias torrent.thedreamers.idle.ro
DocumentRoot C:\xampp\htdocs\torrent.thedreamers.idle.ro
</VirtualHost>

ok.... so ... i want to add this subdomain
i have added C:\WINDOWS\system32\drivers\etc\host
this line
Code: Select all
127.0.0.1       www.thedreamers.idle.ro
127.0.0.1       torrent.thedreamers.idle.ro

to my machine i can connect to this addres
http://www.thedreamers.idle.ro
torrent.thedreamers.idle.ro
other people can't connect to my subdomain..... torrent......
only to http://www.thedreamers.idle.ro

so... where i have proceed wrong???
Ginno
 
Posts: 1
Joined: 25. February 2009 21:18

Re: Subdomain with XAMPP

Postby Wiedmann » 25. February 2009 21:58

i have this domain thedreamers.idle.ro

You have two (official) domains: "thedreamers.idle.ro" and "www.thedreamers.idle.ro".

other people can't connect to my subdomain..... torrent......
only to http://www.thedreamers.idle.ro

And that's the reason people can only connect to the above domains. Talk to your domain registrar how to add additional domains.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Subdomain with XAMPP

Postby Izzy » 26. February 2009 00:09

From a domain name look up I see:
thedreamers.idle.ro.
86.121.109.55

Is that correct and the IP is where the XAMPP server is located?

When I go to http://thedreamers.idle.ro I see a web site GINNO as does HTTP://www.thedreamers.idle.ro

http://torrent.thedreamers.idle.ro fails with address could not be found as does http://www.torrent.thedreamers.idle.ro

So you must add torrent.thedreamers.idle.ro to your zone file at your registrar or where ever you have your DNS Zone File located, to point to your IP much like you did for your main domain name - at my zone file service the www. is auto added to a domain name or sub domain name but you will have to make sure at your own zone file service.

Try this vhost conf and see if it helps after all your zone file edits are in place:
Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName thedreamers.idle.ro
ServerAlias www.thedreamers.idle.ro
DocumentRoot "C:/xampp/htdocs/www"
</VirtualHost>


<VirtualHost *:80>
ServerName torrent.thedreamers.idle.ro
ServerAlias www.torrent.thedreamers.idle.ro
DocumentRoot "C:/xampp/htdocs/torrent.thedreamers.idle.ro"
</VirtualHost>



The hosts file to allow locahost access - no need for www. here:
Code: Select all
127.0.0.1       thedreamers.idle.ro
127.0.0.1       torrent.thedreamers.idle.ro
Last edited by Izzy on 12. March 2009 10:27, edited 2 times in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Subdomain with XAMPP

Postby Wiedmann » 26. February 2009 00:37

http://torrent.thedreamers.idle.ro fails with address could not be found

If no official dns server knows this hostname (domain), you can't access this host from the internet.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Subdomain with XAMPP

Postby DoctorXonlinE » 14. March 2009 19:54

In my DNS settings, I have

Code: Select all
A Record     *.worldofdanproductions.com     my.ip.addy.here


in httpd.conf I've already uncommented the line to include httpd-vhosts.conf.

in httpd-vhosts.conf I have

Code: Select all
NameVirtualHost *:80

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

<VirtualHost *:80>
 DocumentRoot C:/webserver/xampp/htdocs/fight/
 ServerName fight.worldofdanproductions.com
 ServerAlias www.fight.worldofdanproductions.com
</VirtualHost>


Yet, when I go to http://fight.worldofdanproductions.com/ it still takes me to the default www.worldofdanproductions.com index.php.

I'm also having trouble setting up Mercury Mail, but that's for a different thread/post/forum...
DoctorXonlinE
 
Posts: 1
Joined: 14. March 2009 19:41

Re: Subdomain with XAMPP

Postby Izzy » 14. March 2009 23:51

http://fight.worldofdanproductions.com
and
http://www.fight.worldofdanproductions.com
Both go to the sites as outlined in your httpd-vhosts.conf file (see below for corrections), also I checked that the server was indeed Apache in XAMPP.
your fight site wrote:Welcome to World of Dan Productions.

If this is not the correct page then check that the folder xampp\htdocs\fight\ is correct or should it be xampp\htdocs\mainwebsite\fight\ folder?
(mainwebsite being your worldofdanproductions folder)
I should see this if the path is corrected:
What is Fight!? Just that. A balls-to-the-walls, no-holds-barred fight to the last man (or woman) standing.


Check also the apache\logs\error.log file and the access.log file.

To check for yourself rather than rely on others, go to:
http://70.84.211.98/co/DomainDossier.vbs.asp
enter fight.worldofdanproductions.com and tick all the boxes or tick the boxes you are interested in knowing the info from.

Corrected httpd-vhosts.conf file:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "C:/webserver/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/webserver/xampp/htdocs/fight"
ServerName fight.worldofdanproductions.com
ServerAlias www.fight.worldofdanproductions.com
</VirtualHost>
Remember to save the file and restart Apache.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 89 guests