vitualhost and name based site problem

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

vitualhost and name based site problem

Postby zeal243 » 15. February 2011 16:17

Hi,

I am using Xampp-Apache for windows.

I have configured mydomain.com(on port 80) and xy.mydomain.com(port 8080) on single IP

mydomain.com is having plain static html site and is working perfectly.
xy.mydomain.com is a webapp written on Java and running on tomcat port 8080
when I run tomcat application on local host my URL is http://localhost:8080/myapplication

I would like above URL should work only in - http://xy.mydomain.com
Is it possible then pls help me in configuration setting.

httpd.conf setting is-- please verify below content for security purpose also

Listen 80
Listen 8080

NameVirtualHost *:80 *:8080

<VirtualHost *:80 *:8080>
ServerName http://www.mydomain.com
ServerAlias mydomain.com *.mydomain
DocumentRoot D:/xampp/htdocs/mydomain
<Directory "D:/xampp/htdocs/mydomain">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



<VirtualHost *:80 *:8080>
ServerName http://www.xy.mydomain
ServerAlias xy.mydomain.com *.xy.mydomain.com

DocumentRoot D:/xampp/tomcat/webapps/myapplication
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">
AllowOverride None
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>





Thanks in Advance
zeal243
 
Posts: 3
Joined: 15. February 2011 15:40

Re: vitualhost and name based site problem

Postby Sharley » 16. February 2011 00:37

zeal243 wrote:I have configured mydomain.com(on port 80) and xy.mydomain.com(port 8080) on single IP

mydomain.com is having plain static html site and is working perfectly.
xy.mydomain.com is a webapp written on Java and running on tomcat port 8080
when I run tomcat application on local host my URL is http://localhost:8080/myapplication

I would like above URL should work only in - http://xy.mydomain.com
Is it possible then pls help me in configuration setting.

httpd.conf setting is-- please verify below content for security purpose also

Listen 80
Listen 8080

NameVirtualHost *:80 *:8080

<VirtualHost *:80 *:8080>
ServerName http://www.mydomain.com
ServerAlias mydomain.com *.mydomain
DocumentRoot D:/xampp/htdocs/mydomain
<Directory "D:/xampp/htdocs/mydomain">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80 *:8080>
ServerName http://www.xy.mydomain
ServerAlias xy.mydomain.com *.xy.mydomain.com

DocumentRoot D:/xampp/tomcat/webapps/myapplication
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">
AllowOverride None
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
First don't use the httpd.conf file for this.
So delete the above entries and revert to the default settings after you installed XAMPP.

Instead use the correct C:\xampp\apache\conf\extra\httpd-vhosts.conf file.

Try copy and paste this into the httpd-vhosts.conf file and see if it works as you had some issues with what you posted - post back if you have problems with it or if it works:
Code: Select all
NameVirtualHost *:80

<VirtualHosts *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHosts>

<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain
DocumentRoot "D:/xampp/htdocs/mydomain"   
<Directory "D:/xampp/htdocs/mydomain">   
AllowOverride All   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory> 
</VirtualHost>

NameVirtualHost *:8080

<VirtualHost *:8080>
ServerName xy.mydomain.com
ServerAlias *.xy.mydomain.com   
DocumentRoot "D:/xampp/tomcat/webapps/myapplication"
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">   
AllowOverride None   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory>   
 </VirtualHost>
Save the file and restart Apache.

In your Windows hosts file add these entries if they are not already entered at the start of the file
Code: Select all
127.0.0.1 localhost
127.0.0.1 mydomain.com
127.0.0.1 xy.mydomain.com


What version of XAMPP?

Open a command prompt in the C:\xampp\apache\bin folder and issue the command apache -S to check that you have a correct syntax or in the XAMPP Control Panel click on the Shell button and issue the same command.

If Apache can't start check the C:\xampp\apache\logs\error.log file for clues.

This post will be moved to the XAMPP for Windows in English forum.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: vitualhost and name based site problem

Postby zeal243 » 16. February 2011 08:14

Thanks Sharley for your advice. I tried doing all one by one as suggested.
I am using Xampp 1.7.4 win32 version
I reinstalled Xampp and left httpd.conf in original format.
I copied all httpd-vhosts.conf content and tried to start apache. Apache doesn't start and there is no error log file in xampp\apache\logs folder. When tried checking apache -S in \xampp\apache\bin folder then following mssg comes

'apache-s' is not recognized as an internal or external command
operable program or batch file.

Also Shell is not visible in my Xampp control panel after re installation of xampp.

Pls suggest

Thanks




Sharley wrote:
zeal243 wrote:I have configured mydomain.com(on port 80) and xy.mydomain.com(port 8080) on single IP

mydomain.com is having plain static html site and is working perfectly.
xy.mydomain.com is a webapp written on Java and running on tomcat port 8080
when I run tomcat application on local host my URL is http://localhost:8080/myapplication

I would like above URL should work only in - http://xy.mydomain.com
Is it possible then pls help me in configuration setting.

httpd.conf setting is-- please verify below content for security purpose also

Listen 80
Listen 8080

NameVirtualHost *:80 *:8080

<VirtualHost *:80 *:8080>
ServerName http://www.mydomain.com
ServerAlias mydomain.com *.mydomain
DocumentRoot D:/xampp/htdocs/mydomain
<Directory "D:/xampp/htdocs/mydomain">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80 *:8080>
ServerName http://www.xy.mydomain
ServerAlias xy.mydomain.com *.xy.mydomain.com

DocumentRoot D:/xampp/tomcat/webapps/myapplication
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">
AllowOverride None
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
First don't use the httpd.conf file for this.
So delete the above entries and revert to the default settings after you installed XAMPP.

Instead use the correct C:\xampp\apache\conf\extra\httpd-vhosts.conf file.

Try copy and paste this into the httpd-vhosts.conf file and see if it works as you had some issues with what you posted - post back if you have problems with it or if it works:
Code: Select all
NameVirtualHost *:80

<VirtualHosts *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHosts>

<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain
DocumentRoot "D:/xampp/htdocs/mydomain"   
<Directory "D:/xampp/htdocs/mydomain">   
AllowOverride All   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory> 
</VirtualHost>

NameVirtualHost *:8080

<VirtualHost *:8080>
ServerName xy.mydomain.com
ServerAlias *.xy.mydomain.com   
DocumentRoot "D:/xampp/tomcat/webapps/myapplication"
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">   
AllowOverride None   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory>   
 </VirtualHost>
Save the file and restart Apache.

In your Windows hosts file add these entries if they are not already entered at the start of the file
Code: Select all
127.0.0.1 localhost
127.0.0.1 mydomain.com
127.0.0.1 xy.mydomain.com


What version of XAMPP?

Open a command prompt in the C:\xampp\apache\bin folder and issue the command apache -S to check that you have a correct syntax or in the XAMPP Control Panel click on the Shell button and issue the same command.

If Apache can't start check the C:\xampp\apache\logs\error.log file for clues.

This post will be moved to the XAMPP for Windows in English forum.
zeal243
 
Posts: 3
Joined: 15. February 2011 15:40

Re: vitualhost and name based site problem

Postby Sharley » 16. February 2011 10:24

Copy and paste this corrected code below over what you have in your httpd-vhosts.conf file, save and try and restart Apache again:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
DocumentRoot "D:/xampp/htdocs/mydomain"   
<Directory "D:/xampp/htdocs/mydomain">   
AllowOverride All   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory> 
</VirtualHost>

NameVirtualHost *:8080

<VirtualHost *:8080>
ServerName xy.mydomain.com
DocumentRoot "D:/xampp/tomcat/webapps/myapplication"
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">   
AllowOverride None   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory>   
</VirtualHost>
These links should work now.
http://mydomain.com
http://xy.mydomain.com:8080
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: vitualhost and name based site problem

Postby zeal243 » 16. February 2011 10:36

Thanks for quick reply
Yes with this code below links are working. These links are also working with the code which I mentioned in my first communication
I want links to be-

http://mydomain.com and http://xy.mydomain.com (without port 8080)

Is there any way to do so.

Thanks



Sharley wrote:Copy and paste this corrected code below over what you have in your httpd-vhosts.conf file, save and try and restart Apache again:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
DocumentRoot "D:/xampp/htdocs/mydomain"   
<Directory "D:/xampp/htdocs/mydomain">   
AllowOverride All   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory> 
</VirtualHost>

NameVirtualHost *:8080

<VirtualHost *:8080>
ServerName xy.mydomain.com
DocumentRoot "D:/xampp/tomcat/webapps/myapplication"
DirectoryIndex main.html main.swf
<Directory "D:/xampp/tomcat/webapps/myapplication">   
AllowOverride None   
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny       
Allow from all
</Directory>   
</VirtualHost>
These links should work now.
http://mydomain.com
http://xy.mydomain.com:8080
zeal243
 
Posts: 3
Joined: 15. February 2011 15:40

Re: vitualhost and name based site problem

Postby Sharley » 16. February 2011 11:07

As far as I know it is not possible to run 2 servers on the same port, so you have to define which port the servers are listening on.

Tomcat server is listening on port 8080 and Apache is listening on port 80.

So your URI should always define the port number that is not the default web server.
http://localhost:8080 is the default URI for Tomcat in all the documentation I have read.

From the RUNNING.txt file in the tomcat folder
(3.2) After startup, the default web applications included with Tomcat will be available by visiting:
http://localhost:8080/


From the Tomcat Wiki:
http://wiki.apache.org/tomcat/HowTo
After successfully installing Tomcat, you usually test it by loading http://localhost:8080 . The contents of that page are compiled into the index_jsp servlet.

There may be some help reading these Search Results
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: vitualhost and name based site problem

Postby Sharley » 16. February 2011 11:29

You may be able to dispense with the Apache virtual host entry for your tomcat and edit files in the tomcat folder:
http://tomcat.apache.org/tomcat-7.0-doc ... howto.html
The above doc refers to nix but it does say to modify paths if using Windows.

Also you may be able to have tomcat run on port 80 but you could not start Apache and Tomcat at the same time.

The rest of the tomcat docs are here:
http://tomcat.apache.org/tomcat-7.0-doc/index.html

Hope this is of more help.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: vitualhost and name based site problem

Postby ravpxl » 26. July 2012 17:28

I believe I'm having this same issue, butI can't seem to resolve it. I've tried every possible suggestion I could find, from changing the port numbers to unchecking the port 80 setting in Skype.

So, my issue is this:

I have xampp installed on a separate pc right next to me, and everything works fine. localhost works, and if I type in the url to my virtual host, http://myvirtualhost/ the index.html file in c:/xampp/htdocs/myvirtualhost directory
loads up as expected.

When I go to my other pc, that is connected through the network router, I can access the contents of myvirtualhost just fine, but only if I use the ip address. Once I use http://myvirtualhost/ ServerAlias, it ends up taking me to google or yahoo and I get a message that it can't find the website.

For all intensive purposes it's working, except that I cant use http://myvirtualhost/, unless its on the pc where I have xampp installed, or if I use the specific ip address.
ravpxl
 
Posts: 5
Joined: 26. July 2012 17:02
Operating System: windows

Re: vitualhost and name based site problem

Postby JonB » 26. July 2012 17:53

you probably need a hosts file entry on the second machine that points to the IP of the XAMPP host

Code: Select all
192.168.n.nnn   http://myvirtualhost


Good Luck
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: vitualhost and name based site problem

Postby ravpxl » 27. July 2012 17:12

I have that set up already, but not with the http:// in front, and it works. But only with the IP address, not the servername.

I have the same set up as Sharley mentioned with the vhosts and no alias. I've tried aliases as well,
but nothing.

It's seriously frustrating trying to get the vanity url to work on the network pc other than the server. There doesn't seem to be much to this setup,
and I can't get it to work with out using the ip address. I'm at a loss as to what the missing piece is. I basically want to access the server from any pc on
the network using something like http://mydomain

Is there some sort of hack or workaround, maybe using redirects?

Thanks
ravpxl
 
Posts: 5
Joined: 26. July 2012 17:02
Operating System: windows

Re: vitualhost and name based site problem

Postby JonB » 28. July 2012 00:29

If you want a URL other than the IP, AND it is not a registered Domain Name with nameservers, you must create entries in the 'hosts' file on each of the client machines.

if your sever was 192.168.0.14 and the vhost ServerName was mydomain.local the entry would be

Code: Select all
192.168.0.14  mydomain.local


Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: vitualhost and name based site problem

Postby ravpxl » 30. July 2012 22:22

No luck with that. I previously tried it, and it's the same issue. It works fine on the pc with the xampp install but not the one i'm trying to access it from.
I uninstalled and reinstalled to get a fresh start, and nothing has changed.

The thread mentioned looking at the apache error logs, it mentions the SSLSessionCache not being configured, but I'm not sure how that plays into it. Here are
the log messages, in case that helps:

AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
AH00455: Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4 configured -- resuming normal operations
AH00456: Server built: May 13 2012 14:10:15
AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
AH00418: Parent: Created child process 5196
AH00548: NameVirtualHost has no effect and will be removed in the next release C:/xampp/apache/conf/extra/httpd-vhosts.conf:45
AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
AH00354: Child: Starting 150 worker threads.

Thanks again trying to help me sort this out.
ravpxl
 
Posts: 5
Joined: 26. July 2012 17:02
Operating System: windows

Re: vitualhost and name based site problem

Postby JonB » 30. July 2012 23:08

please post the relevant section of \apache\conf\extra\httdp-vhosts.conf - if possible

The SessionCache is an error, but it is common to all 1.8.0 installs - its not your problem

note - as it says, the NameVirtualHost directive is fully deprecated/obsoleted, you can just remove it or comment it out.

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: vitualhost and name based site problem

Postby ravpxl » 31. July 2012 15:03

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName mydomainfolder.local
ServerAlias *.mydomainfolder.local
DocumentRoot "C:/xampp/htdocs/mydomainfolder"
<Directory "C:/xampp/htdocs/mydomainfolder">
AllowOverride All
#Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

host file contains:
127.0.0.1 localhost
192.168.nn.nnn mydomainfolder.local
ravpxl
 
Posts: 5
Joined: 26. July 2012 17:02
Operating System: windows

Re: vitualhost and name based site problem

Postby JonB » 31. July 2012 15:20

A. You have embedded (one of) your virtual host(s) inside your primary DocumentRoot. It still should work, but it an awful practice from a security standpoint.

EFFECTIVELY - http://localhost/mydomainfolder and mydomainfolder.local are indistinguishable and because of the way .htaccess works you might have unintended outcomes.

B. Is there a copy of this line in all those other machines 'hosts' files?
192.168.nn.nnn mydomainfolder.local

if not, that is your problem.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 91 guests