VHosts with http access?!?

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

VHosts with http access?!?

Postby jmansa » 03. March 2007 18:44

Have to gettin' bored with all the vhost questions, but I cant seem to figure this out!

I'm trying to host my own homepages (2) and have the dns for the domains pointing at my IP adress. I have then set up my httpd-vhost file setup like this.

NameVirtualHost *:80

<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot C:/Program Files/xampp/htdocs/site1.com
</VirtualHost>

<VirtualHost *:80>
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot C:/Program Files/xampp/htdocs/site2.com
</VirtualHost>

Everything else I havent touched.

Now, everytime I try to call on one of the sites e.g. www.site1.com or www.site2.com from a computer outside my router environment it directs me to the rootfolder og htdocs e.g. xampp for windows startpage!?

Can't figure out where I'm going wrong...Somebody please help me!
jmansa
 
Posts: 5
Joined: 03. March 2007 18:32

Postby ntsmarkv » 04. March 2007 18:48

DocumentRoot C:/Program Files/xampp/htdocs/site1.com


Hmm, this is your main concern right here, that is not pointing to no directory..

try:
Code: Select all
 DocumentRoot C:/Program Files/xampp/htdocs/site1/


where site1 is a folder..
ntsmarkv
 
Posts: 32
Joined: 22. October 2005 21:38

Postby WorldDrknss » 05. March 2007 08:40

If you create the following folders in each site directory (site1.com & site2.com directories) : cgi-bin, logs, errors you can use the following VirtualHost. Also paths that have spaces in them need to be quoted.

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>
ServerName site1.com
ServerAdmin webmaster@site1.com
ServerAlias www.site1.com
DocumentRoot "C:/Program Files/xampp/htdocs/site1.com"
<Directory "C:/Program Files/xampp/htdocs/site1.com">
Options            Indexes FollowSymLinks Includes ExecCGI
AllowOverride      All
Order              allow,deny
Allow              from all
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddHandler server-parsed .html .htm .shtml .shtm
</Directory>
<Directory "C:/Program Files/xampp/htdocs/site1.com/logs">
Deny from all
</directory>
HostnameLookups    Off
ErrorLog           "C:/Program Files/xampp/htdocs/site1.com/logs/error.log"
LogFormat           "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat           "%h %l %u %t \"%r\" %>s %b" common
LogFormat           "%{Referer}i -> %U" referer
LogFormat           "%{User-agent}i" agent
CustomLog          "C:/Program Files/xampp/htdocs/site1.com/logs/access.log combined"
ServerSignature    On
ScriptAlias        /cgi-bin/  "C:/Program Files/xampp/htdocs/site1.com/cgi-bin/"
<Directory "C:/Program Files/xampp/htdocs/site1.com/cgi-bin">
AllowOverride      None
Options            None
Order              allow,deny
Allow              from all
</Directory>
DirectoryIndex     index.php index.html index.htm index.shtml index.shtm
AccessFileName     .htaccess
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
AddHandler         cgi-script .cgi
<IfModule mod_negotiation>
<IfModule mod_include>
Alias /errors/ "C:/Program Files/xampp/htdocs/site1.com/errors/"
<Directory "C:/Program Files/xampp/htdocs/site1.com/errors">
AllowOverride None
Options IncludesNoExec
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en
</Directory>
</IfModule>
</IfModule>
ErrorDocument 400 /errors/400.html
ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 405 /errors/405.html
ErrorDocument 408 /errors/408.html
ErrorDocument 410 /errors/410.html
ErrorDocument 411 /errors/411.html
ErrorDocument 412 /errors/412.html
ErrorDocument 413 /errors/413.html
ErrorDocument 414 /errors/414.html
ErrorDocument 415 /errors/415.html
ErrorDocument 500 /errors/500.html
ErrorDocument 501 /errors/501.html
ErrorDocument 502 /errors/502.html
ErrorDocument 503 /errors/503.html
ErrorDocument 506 /errors/506.html
</VirtualHost>

<VirtualHost *:80>
ServerName site2.com
ServerAdmin webmaster@site2.com
ServerAlias www.site2.com
DocumentRoot "C:/Program Files/xampp/htdocs/site2.com"
<Directory "C:/Program Files/xampp/htdocs/site2.com">
Options            Indexes FollowSymLinks Includes ExecCGI
AllowOverride      All
Order              allow,deny
Allow              from all
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddHandler server-parsed .html .htm .shtml .shtm
</Directory>
<Directory "C:/Program Files/xampp/htdocs/site2.com/logs">
Deny from all
</directory>
HostnameLookups    Off
ErrorLog           "C:/Program Files/xampp/htdocs/site2.com/logs/error.log"
LogFormat           "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat           "%h %l %u %t \"%r\" %>s %b" common
LogFormat           "%{Referer}i -> %U" referer
LogFormat           "%{User-agent}i" agent
CustomLog          "C:/Program Files/xampp/htdocs/site2.com/logs/access.log combined"
ServerSignature    On
ScriptAlias        /cgi-bin/  "C:/Program Files/xampp/htdocs/site2.com/cgi-bin/"
<Directory "C:/Program Files/xampp/htdocs/site2.com/cgi-bin">
AllowOverride      None
Options            None
Order              allow,deny
Allow              from all
</Directory>
DirectoryIndex     index.php index.html index.htm index.shtml index.shtm
AccessFileName     .htaccess
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
AddHandler         cgi-script .cgi
<IfModule mod_negotiation>
<IfModule mod_include>
Alias /errors/ "C:/Program Files/xampp/htdocs/site2.com/errors/"
<Directory "C:/Program Files/xampp/htdocs/site2.com/errors">
AllowOverride None
Options IncludesNoExec
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en
</Directory>
</IfModule>
</IfModule>
ErrorDocument 400 /errors/400.html
ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 405 /errors/405.html
ErrorDocument 408 /errors/408.html
ErrorDocument 410 /errors/410.html
ErrorDocument 411 /errors/411.html
ErrorDocument 412 /errors/412.html
ErrorDocument 413 /errors/413.html
ErrorDocument 414 /errors/414.html
ErrorDocument 415 /errors/415.html
ErrorDocument 500 /errors/500.html
ErrorDocument 501 /errors/501.html
ErrorDocument 502 /errors/502.html
ErrorDocument 503 /errors/503.html
ErrorDocument 506 /errors/506.html
</VirtualHost>

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Program Files/xampp/htdocs"
</VirtualHost>
http://wdguides.org - XAMPP Tutorials & MORE!!!!
User avatar
WorldDrknss
 
Posts: 292
Joined: 17. September 2005 13:40

Postby jmansa » 05. March 2007 09:36

I tryid the example above, but still got the same outcome. It still directs me to the xampp root folder (localhost) and asks me to login. I'ts tearing me apart... Any idea?
jmansa
 
Posts: 5
Joined: 03. March 2007 18:32

Postby WorldDrknss » 05. March 2007 09:54

Are you making sure to restart Apache once you have made these changes?
http://wdguides.org - XAMPP Tutorials & MORE!!!!
User avatar
WorldDrknss
 
Posts: 292
Joined: 17. September 2005 13:40

Postby jmansa » 05. March 2007 11:09

Finally!!! It works. It was the restart thingy! I encountered one problem though! When I pasted this part of the above code my apache wouldnt restart?
Code: Select all
HostnameLookups    Off
ErrorLog           "C:/Program Files/xampp/htdocs/site2.com/logs/error.log"
LogFormat           "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat           "%h %l %u %t \"%r\" %>s %b" common
LogFormat           "%{Referer}i -> %U" referer
LogFormat           "%{User-agent}i" agent
CustomLog          "C:/Program Files/xampp/htdocs/site2.com/logs/access.log combined"
ServerSignature    On
ScriptAlias        /cgi-bin/  "C:/Program Files/xampp/htdocs/site2.com/cgi-bin/"
<Directory "C:/Program Files/xampp/htdocs/site2.com/cgi-bin">
AllowOverride      None
Options            None
Order              allow,deny
Allow              from all
</Directory>


Also I have a problem seing the pages from inside my router from another computer... When on my webserver writes "localhost/site1.com" it shows the page perfect, but when I try to acces the page from another computer on my network by typing "192.168.1.???/site1.com" I get this error!

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404
192.168.1.???
03/05/07 11:07:11
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.1


Any idea?

One question more... How is it possible to make a index.html overrule a index.php? as it is now my index.php always gets shown

Thanks alot
jmansa
 
Posts: 5
Joined: 03. March 2007 18:32

Postby WorldDrknss » 05. March 2007 12:49

Change:
Code: Select all
HostnameLookups    Off
ErrorLog           "C:/Program Files/xampp/htdocs/site2.com/logs/error.log"
LogFormat           "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat           "%h %l %u %t \"%r\" %>s %b" common
LogFormat           "%{Referer}i -> %U" referer
LogFormat           "%{User-agent}i" agent
CustomLog          "C:/Program Files/xampp/htdocs/site2.com/logs/access.log combined"
ServerSignature    On
ScriptAlias        /cgi-bin/  "C:/Program Files/xampp/htdocs/site2.com/cgi-bin/"
<Directory "C:/Program Files/xampp/htdocs/site2.com/cgi-bin">
AllowOverride      None
Options            None
Order              allow,deny
Allow              from all
</Directory>


To
Code: Select all
HostnameLookups    Off
ErrorLog           "C:/Program Files/xampp/htdocs/site2.com/logs/error.log"
LogFormat           "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat           "%h %l %u %t \"%r\" %>s %b" common
LogFormat           "%{Referer}i -> %U" referer
LogFormat           "%{User-agent}i" agent
CustomLog          "C:/Program Files/xampp/htdocs/site2.com/logs/access.log" combined
ServerSignature    On
ScriptAlias        /cgi-bin/  "C:/Program Files/xampp/htdocs/site2.com/cgi-bin/"
<Directory "C:/Program Files/xampp/htdocs/site2.com/cgi-bin">
AllowOverride      None
Options            None
Order              allow,deny
Allow              from all
</Directory>


Then change:
Code: Select all
DirectoryIndex     index.php index.html index.htm index.shtml index.shtm


To:
Code: Select all
DirectoryIndex     index.html index.php index.htm index.shtml index.shtm


Then change:
Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Program Files/xampp/htdocs"
</VirtualHost>


To:
Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Program Files/xampp/htdocs"
<Directory "C:/Program Files/xampp/htdocs">
Options            Indexes FollowSymLinks Includes ExecCGI
AllowOverride      All
Order              allow,deny
Allow              from all
</Directory>
</VirtualHost>


and see how that works out for you.
Also make sure the following exists.
Code: Select all
C:/Program Files/xampp/htdocs/site1.com/cgi-bin
C:/Program Files/xampp/htdocs/site1.com/logs
C:/Program Files/xampp/htdocs/site1.com/errors

C:/Program Files/xampp/htdocs/site2.com/cgi-bin
C:/Program Files/xampp/htdocs/site2.com/logs
C:/Program Files/xampp/htdocs/site2.com/errors
http://wdguides.org - XAMPP Tutorials & MORE!!!!
User avatar
WorldDrknss
 
Posts: 292
Joined: 17. September 2005 13:40

Postby jmansa » 05. March 2007 14:22

That help allthough I still can't see the pages within the network. Now I get an "http 404"?
jmansa
 
Posts: 5
Joined: 03. March 2007 18:32

Postby WorldDrknss » 05. March 2007 23:32

Is there a reason you need to access it via IP vs. the domain name?
You may want to give this a try:
On the machine your trying to get onto the site open
Code: Select all
C:\WINDOWS\system32\drivers\etc\hosts
and change it to look similar to whats below.
Code: Select all
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
192.168.1.*     site1.com
192.168.1.*     site2.com


Make sure to replace * with the last number for that IP. <- also double check that your server is set to static ip instead of windows default dynamic ip.

Then access your site via http://site1.com and http://site2.com -> this will let you access your site within network using the actual domain name.
http://wdguides.org - XAMPP Tutorials & MORE!!!!
User avatar
WorldDrknss
 
Posts: 292
Joined: 17. September 2005 13:40


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 110 guests