Hosting 2 websites accessibly by public using XAMPP

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

Hosting 2 websites accessibly by public using XAMPP

Postby yolkie » 15. October 2010 08:13

Hello all,

I have a website hosted by XAMPP. Lets call this Website A.

Website A is available to the public. Now I need to find a way to create a second website accessible by public too (Website B), on the same server, using the same XAMPP. I have googled and came across XAMPP virtual hosts. But virtual hosts is for creating multiple websites in a local environment (correct me if i am wrong). In Microsoft IIS, you can host multiple websites accessible by public but is there anyway to do the same thing in XAMPP?

Website A: http://www.websiteA.com
Public IP of website A: 203.125.xxx.xxx (already up and running)
Did a NAT of public IP into internal IP.

Website B criteria: http://www.websiteB.com
Do I need a different public IP address?
Do I need a different internal IP address?

I am new to XAMPP.

Would appreciate if anyone can lend thier helping hand.

Cheers!
yolkie
 
Posts: 4
Joined: 25. August 2010 05:36

Re: Hosting 2 websites accessibly by public using XAMPP

Postby Nobbie » 15. October 2010 12:18

yolkie wrote: But virtual hosts is for creating multiple websites in a local environment (correct me if i am wrong)


Herewith i correct you: your are wrong.

VirtualHosts is the solution you are looking for. There are two basics kinds of VirtualHosts, one the is IP Based VirtualHost (what means, that each domain name has its own IP) and the NameBased VirtualHost (what means, that the domains share the same IP) which perfectly meats your needs. It is suited for any environment, there is no restriction to local environment.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: Hosting 2 websites accessibly by public using XAMPP

Postby Dariusc123456 » 15. October 2010 15:29

Goto C:\xampp\apache\conf\extra\httpd-vhosts.conf and see how the vhost is set up. Here is a great example to get you started:

Code: Select all
<VirtualHost *:80>
    ServerAdmin postmaster@example.com
    DocumentRoot "/xampp/htdocs/example.com/htdocs/www/"
    ServerName example.com
    ServerAlias www.example.com
    ErrorLog "/xampp/htdocs/example.com/logs/error.log"
    CustomLog "/xampp/htdocs/example.com/logs/access.log" combined
    <Directory "/xampp/htdocs/example.com/htdocs/www/">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Allow from all
    </Directory>
    <IfModule php5_module>
        php_admin_flag safe_mode Off
        php_admin_value upload_tmp_dir "/xampp/htdocs/example.com/tmp/"
    </IfModule>   
</VirtualHost>


My virtual host is setup differently because I host websites for others so you can edit the vhost right there to fit how you want it to be but create a folder called example.com in C:/xampp/htdocs/ and then inside that folder create the following folders:
htdocs
tmp
logs
ssl

then inside the C:/xampp/htdocs/example.com/htdocs/ directory, create the folder "www" and place any content you want inside of it. This is a very good way to keep everything manage, and also remember to replace the example.com with your own domain. If you need too, use mod_rewrite with vhost to make it easier to make host websites so you dont have to restart your server so many times.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Hosting 2 websites accessibly by public using XAMPP

Postby yolkie » 16. October 2010 08:20

Thank you both for your response.

For this:
<VirtualHost *:80>
ServerAdmin postmaster@example.com
DocumentRoot "/xampp/htdocs/example.com/htdocs/www/"
ServerName example.com
ServerAlias www.example.com
ErrorLog "/xampp/htdocs/example.com/logs/error.log"
CustomLog "/xampp/htdocs/example.com/logs/access.log" combined
<Directory "/xampp/htdocs/example.com/htdocs/www/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from all
</Directory>
<IfModule php5_module>
php_admin_flag safe_mode Off
php_admin_value upload_tmp_dir "/xampp/htdocs/example.com/tmp/"
</IfModule>
</VirtualHost>

What do I put in here: <VirtualHost *:80>
Do i put <VirtualHost (public ip):80> or private ip?
yolkie
 
Posts: 4
Joined: 25. August 2010 05:36

Re: Hosting 2 websites accessibly by public using XAMPP

Postby Nobbie » 16. October 2010 11:16

yolkie wrote:What do I put in here: <VirtualHost *:80>
Do i put <VirtualHost (public ip):80> or private ip?


You may leave there the wildcard. If you prefer an IP, it must be the private IP (not the public!). I assume, your server is running behind a router, therefore the public is the routers IP, which is unknown to your local Apache.

Anyway, either you decide to leave the *:80 or replace it be the private IP, this entry must precisely match the value you choose for the "NameVirtualHost" Directive (which is missing yet completely):

Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>
   ServerName www.domainA.com
....
</VirtualHost>
<VirtualHost *:80>
   ServerName www.domainB.com
....
</VirtualHost>


or

Code: Select all
NameVirtualHost 192.168.100.100:80
<VirtualHost 192.168.100.100:80>
   ServerName www.domainA.com
....
</VirtualHost>
<VirtualHost 192.168.100.100:80>
   ServerName www.domainB.com
....
</VirtualHost>


And read the docu about NameBased VirtualHosts!
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: Hosting 2 websites accessibly by public using XAMPP

Postby Dariusc123456 » 16. October 2010 19:18

yolkie wrote:Thank you both for your response.

For this:
<VirtualHost *:80>
ServerAdmin postmaster@example.com
DocumentRoot "/xampp/htdocs/example.com/htdocs/www/"
ServerName example.com
ServerAlias http://www.example.com
ErrorLog "/xampp/htdocs/example.com/logs/error.log"
CustomLog "/xampp/htdocs/example.com/logs/access.log" combined
<Directory "/xampp/htdocs/example.com/htdocs/www/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from all
</Directory>
<IfModule php5_module>
php_admin_flag safe_mode Off
php_admin_value upload_tmp_dir "/xampp/htdocs/example.com/tmp/"
</IfModule>
</VirtualHost>

What do I put in here: <VirtualHost *:80>
Do i put <VirtualHost (public ip):80> or private ip?


I recommend you leaving it as a wildcard.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 98 guests