Page 1 of 1

Have two websites running on the same server - using XAMPP

PostPosted: 09. March 2010 16:26
by MichaelBoyeOlsen
Hi all.
Sorry, I'm a bit of a noob to all this :)

I have two domains:
domain1
domain2

Is it possible to have both domains running on the same server?
Like this:
domain1 points to http://www.domain1.com
domaint2 points to http://www.domain2.com

- I know it is possible in IIS and WampServer.
But I don't know how to do it here.

Hope you guys can help me.

Best Regards,
Michael

Re: Have two websites running on the same server - using XAMPP

PostPosted: 09. March 2010 16:54
by Stepke-DSL
Hi,

Sure, it is possible to have 2 domains on the same server.
You have to look for virtualhosts...

Best Regards,
Stepke

Re: Have two websites running on the same server - using XAMPP

PostPosted: 09. March 2010 17:00
by MichaelBoyeOlsen
Great - I'll do that - thanks :)

Re: Have two websites running on the same server - using XAMPP

PostPosted: 10. March 2010 22:27
by MichaelBoyeOlsen
Hi again.
I have tried to search for it, but I can't find anything about how to make it happen.
Could anyone tell me how to do it, step by step?
I want this webpage: www.mydomain.com
to point in to this folder: C:\xampp\htdocs\mydomain

Is there anything else you need to guide me?

- Again, sorry I'm a bit of a noob to all this.
Hope someone can help.

Best Regards,
Michael

Re: Have two websites running on the same server - using XAMPP

PostPosted: 11. March 2010 01:12
by CraigS
Open up httpd-vhosts.conf under /xampp/apache/conf/extra
Change:
Code: Select all
#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80

#
# VirtualHost example:
#

To:
Code: Select all
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
#


Then scroll down a bit you will see:
Code: Select all
##<VirtualHost *:80>
    ##ServerAdmin postmaster@dummy-host.localhost
    ##DocumentRoot "C:/xampppy/xampp/htdocs/dummy-host.localhost"
    ##ServerName dummy-host.localhost
    ##ServerAlias www.dummy-host.localhost
    ##ErrorLog "logs/dummy-host.localhost-error.log"
    ##CustomLog "logs/dummy-host.localhost-access.log" combined
##</VirtualHost>

##<VirtualHost *:80>
    ##ServerAdmin postmaster@dummy-host2.localhost
    ##DocumentRoot "C:/xampppy/xampp/htdocs/dummy-host2.localhost"
    ##ServerName dummy-host2.localhost
    ##ServerAlias www.dummy-host2.localhost
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</VirtualHost>


Here is an example of mine i use on my server (you can add this at the end of the file):
Code: Select all
<VirtualHost *:80>
    DocumentRoot C:\xampp\htdocs\craigsbe
    ServerName CraigS.be
    ServerAlias www.CraigS.be
</VirtualHost>


In the above you can see ServerName and Server Alias, what these do is tell apache to 'listen' for requests for Craigs.be and http://www.Craigs.be

Edit: To have this work, you MUST have the domain name actually point to the server, the apache server gets the domain info from the browser; Also if you check the documentation, the first entry in this table will be the default site that will load up if you do not specify a name (such as entering in the servers ip address) (For example i have craigs1.be and craigs2.be listed under the same ip address, when i go to the ip address of the server it will load craigs1.be 's site, since again it is listed first.


Hope this helps
Craig S