xampp multiple public domains / virtual hosts

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

xampp multiple public domains / virtual hosts

Postby raymonde1323 » 18. December 2012 07:41

Hi.

Right now I have 5 domains registered at godaddy. I also added those domains to afraid.org and pointed them to my external IP
Im running xampp on windows 7.
xampp is configured for public access

the problem is that all 5 domains point to the same website which is under c:/xampp/htdocs since they all point to the same IP
the other websites are currently

c:/xampp/htdocs/site2
c:/xampp/htdocs/site3
c:/xampp/htdocs/site4

etc...

So what I need help with is this: How do I make it so that the different domains point to different websites on xampp without using the ugly "forward to URL" option. I need clean urls here.

I was thinking virtual hosts would do it, but all the instructions I can find are about subdomains and not regular domains. Also they are always talking about local access and not public access.

So before I get lost in trial and error could someone please give me a few tips here?
Will virtual hosts work?

Also I have read that many people dont recommend using xampp for public websites. I need this to work for now, but it you would like to tell me a different windows or linux solution Im glad to hear it.

Thanks for reading.
raymonde1323
 
Posts: 3
Joined: 18. December 2012 07:09
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: xampp multiple public domains / virtual hosts

Postby amereservant » 18. December 2012 08:01

Yeap, VirtualHosts are the answer. Let me explain sorta how it works ....

When someone visits a domain name, a DNS server connects that domain name to an IP address and just as with any hosting company hosting many websites, there's often only a few IP addresses for all of the hundreds of domain names.
So what happens is that the web server (Apache) detects what domain name brought them to that IP address and then routes the visitor to the correct content.
That routing is done within the virtual hosts files in Apache.

So here's what you need to do ....

  1. If the Apache documentation doesn't make sense regarding Virtual Hosts, http://httpd.apache.org/docs/2.4/vhosts/examples.html, find a good tutorial to help you get going. There's plenty of past discussions on this forum about it.
  2. Understand the ServerName directive in a VirtualHost is how Apache identifies the incoming domain request and directs it to the correct content. So say you have mydomain.com, your ServerName and ServerAlias will be something like:
Code: Select all
ServerName mydomain.com
ServerAlias www.mydomain.com


The rest of the Virtual Host is in regards to directory permissions, error logging, etc.

It's not too complicated once you understand how a URL request works, at least the basic idea of it. Hope that helps.
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
User avatar
amereservant
 
Posts: 16
Joined: 16. December 2012 00:37
Location: Columbus, MS
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: xampp multiple public domains / virtual hosts

Postby amereservant » 18. December 2012 08:50

By the way, I've gone ahead and re-created my tutorial I wrote on this a while back: http://myownhomeserver.com/2012/12/how-to-create-multiple-websites-using-apache-xampp/. I'm gradually working on re-creating my past website by re-creating a lot of the old tutorials with updated materials/etc., it just takes a lot of time doing. Anywho, hope that helps.
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
User avatar
amereservant
 
Posts: 16
Joined: 16. December 2012 00:37
Location: Columbus, MS
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: xampp multiple public domains / virtual hosts

Postby raymonde1323 » 18. December 2012 10:23

thanks a lot. Im still having issues though.

following the instructions on your site my httpd-conf vile now looks like this:

Code: Select all
NameVirtualHost *:80
 
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/myxamppserver/xampp/htdocs"
</VirtualHost>
 
 
 
##  My First Domain    ##
 
<VirtualHost *:80>
    ServerName myfirstdomain.com
    ServerAlias www.myfirstdomain.com
    DocumentRoot "C:/myxamppserver/xampp/htdocs"
</VirtualHost>
 
 
 
##  My Second Domain  ##
 
<VirtualHost *:80>
    ServerName myseconddomain.com
    ServerAlias www.myseconddomain.com
    DocumentRoot "C:/myxamppserver/xampp/htdocs/administrator"
    <Directory "C:/myxamppserver/xampp/htdocs/administrator">
        Options Indexes +FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


however I am getting this error when trying to start apache via cmd

Image

Do you know why this is?
raymonde1323
 
Posts: 3
Joined: 18. December 2012 07:09
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: xampp multiple public domains / virtual hosts

Postby amereservant » 18. December 2012 15:11

Yes, you MUST change the values of ServerName, ServerAlias, and DocumentRoot to match your setup. The one I have on my site is ONLY an example and cannot be used AS-IS.
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
User avatar
amereservant
 
Posts: 16
Joined: 16. December 2012 00:37
Location: Columbus, MS
XAMPP Version: 5.6.3
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 32 guests