Page 1 of 1

Sub-Site

PostPosted: 06. December 2008 15:51
by Munkey
Hi,
Ive managed to get Xampp working on windows perfectly but I would like to have a site within a site. What im looking for is a separate address that goes to a different 'htdocs' folder on the same computer. It doesn't seem possible because I have 1 modem with 1 IP. If so how do the commercial hosting people do it? Have thousands of separeate modems with different IPs and bags of computers? Is it possible, if so how?

Many thanks, Munkey.

Re: Sub-Site

PostPosted: 06. December 2008 15:54
by Nobbie
Google for "Namebased VirtualHost".

Re: Sub-Site

PostPosted: 07. December 2008 10:40
by Munkey
Well that seems to work if your are visiting it on LAN, but what about my external IP and domain, it is still mapped to my IP in which there are 2 'sites' to go to. How do I point a different domain to one of my virtual hosts/(sites?)

Re: Sub-Site

PostPosted: 07. December 2008 14:09
by Nobbie
Munkey wrote:Well that seems to work if your are visiting it on LAN, but what about my external IP and domain, it is still mapped to my IP in which there are 2 'sites' to go to. How do I point a different domain to one of my virtual hosts/(sites?)


What did you try? Please show us your virtual host configuration.

Re: Sub-Site

PostPosted: 07. December 2008 17:01
by Munkey
I copied it of this site: http://www.campbellssource.com/?p=4

But for people outside the localhost name; the other side of my router/modem, how do they get to to the separate site configured on the virtualhosts doc?
Externally (external IP)
www.test1.com <-- resolves to my external IP:80
www.test2.com <-- resolves to my external IP:80 IPs are the same, so how do I redirect www.test1/2.com to the correct V-host?
Internally (127.0.0.1)
test1.com <--resolves to test1 folder with separate website docs
test2.com <--resolves to test1 folder with separate website docs

Hard to explain, but hope you get it.

Re: Sub-Site

PostPosted: 07. December 2008 17:30
by Nobbie
I still need your original virtual host configuration (full code). Please show it here, otherwise i cannot help furthermore.us

P.S.: You must not use 127.0.0.1 as local IP, but instead the LAN IP of the PC, which is supplied by the Router to the PC. Assuming the LAN IP is 192.168.178.31 (replace it by the real LAN IP), you must install a PortForwarding in the Router for all TCP-Requests on port 80 to this IP.

After that you have to define the virtual hosts like this example (replace pathnames and IPs as needed):

Code: Select all
NameVirtualHost 192.168.178.31

<VirtualHost 192.168.178.31>
DocumentRoot c:/xampp/test1
ServerName www.test1.com
<Directory "c:/xampp/test1">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.178.31>
DocumentRoot c:/xampp/test2
ServerName www.test2.com
<Directory "c:/xampp/test2">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


Reboot Apache and after http://www.test1.com will point to c:/xampp/test1 and http://www.test2.com to c:/xampp/test2. As well for local PCs in LAN as for external Requests coming from outside.

Re: Sub-Site

PostPosted: 08. December 2008 21:12
by Munkey
Yup, here is the original V-hosts code:
Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##    ServerAdmin webmaster@dummy-host.example.com
##    DocumentRoot /www/docs/dummy-host.example.com
##    ServerName dummy-host.example.com
##    ServerAlias www.dummy-host.example.com
##    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
##</VirtualHost>

##<VirtualHost *:80>
##    ServerAdmin webmaster@dummy-host2.example.com
##    DocumentRoot /www/docs/dummy-host2.example.com
##    ServerName dummy-host2.example.com
##    ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
##</VirtualHost>




Re: Sub-Site

PostPosted: 08. December 2008 22:31
by Nobbie
Munkey wrote:Yup, here is the original V-hosts code:


Wow - the original Vhosts code. Useless, worthless, everything commented out.

That's what you "tried"? Great.

Did you already try the configuration of my last post?

Re: Sub-Site

PostPosted: 10. December 2008 16:41
by Munkey
Sorry, got the wrong end of that...

Well I used your V-hosts code and changed the IPs to the ones of the machine which it is hosted on, created the test directories and stuck in a index.html page in it then added a fort forwarding rule.

From the computer it is hosted on it comes up with the "Page cannot be displayed" error, from another computer on the same LAN network it just comes up with the DNS error and via a proxy/ remote external IP it comes up with a URL error, the same as bashing the keyboard in the URL box...

Justm thought- What if someone else has the same address: http://www.test.com? Also I thought it cost to get a .com domain...

Any ideas?

Edit: The code I used is:
Code: Select all
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.

NameVirtualHost 192.168.1.100

<VirtualHost 192.168.1.100>
DocumentRoot c:/xampp/test1
ServerName www.test1.com
<Directory "c:/xampp/test1">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.1.100>
DocumentRoot c:/xampp/test2
ServerName www.test2.com
<Directory "c:/xampp/test2">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


Re: Sub-Site

PostPosted: 10. December 2008 16:58
by glitzi85
If you want to use this domains inside your LAN you must edit the hosts file of every computer and add this line:

Code: Select all
192.168.1.100    www.test1.com
192.168.1.100    www.test2.com


Alternatively you can set up an DNS-Server and redirect both domains to your internal Webserver, but that's a little bit more complicated.

glitzi

Re: Sub-Site

PostPosted: 10. December 2008 22:33
by Munkey
Well what I am aiming to do it have 2 or more separate websites hosted on 1 computer with 1 connection. This will be viewed publically on the internet as any other site.

I assumned it can be done because I dont expect big hosting companies to have thousands of separate internet connections/ computers for each site...