wood burning stoves 2.0*
The moose likes Tomcat and the fly likes How to change virtual host from http://localhost/test to http://www.fakedomain.com/? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to change virtual host from http://localhost/test to http://www.fakedomain.com/?" Watch "How to change virtual host from http://localhost/test to http://www.fakedomain.com/?" New topic
Author

How to change virtual host from http://localhost/test to http://www.fakedomain.com/?

Chen Huang
Greenhorn

Joined: May 10, 2008
Posts: 3
Hi

OS: Linux
Tomcat version: 6.0
I want to set up a virtual host for an application (webapps/test). I followed the tomcat 6 documentation:
1. in $CATALINA_HOME/conf/server.xml, add:
2. Created $CATALINA_HOME/webapps/test/ROOT/META-INF/context.xml, this was left empty

After restarting tomcat, when I visit www.fakedomain.com, I got this error:


The project is workable if using http://localhost/test.

Also if I change the server.xml as this

I was able to visit the project by using www.fakedomain/test.

I'm new to tomcat, I wonder if I missed something?

Thanks!
[ May 10, 2008: Message edited by: Chen Huang ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
When I set up virtual hosts, I use an absolute path for appBase.

Bill
Chen Huang
Greenhorn

Joined: May 10, 2008
Posts: 3
Thanks for writing back, I tried that, but it doesn't work...
One thing I don't understand is: why I was able to visit "www.fakedomain.com" if I change appBase to "webapps", in that case the default tomcat page will show up. Does that mean the virtual host work but I might have missed something in my own application?

Originally posted by William Brogden:
When I set up virtual hosts, I use an absolute path for appBase.

Bill
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The appBase shouldn't point to a specific app.
It points to the directory which houses the application folders.

It sounds like you've got it right if you're seeing the Tomcat home page.
Maybe you also want your application to be the default application for that host?

If so, rename your application to "ROOT".


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chen Huang
Greenhorn

Joined: May 10, 2008
Posts: 3
Thanks a lot! That works.

Originally posted by Ben Souther:
The appBase shouldn't point to a specific app.
It points to the directory which houses the application folders.

It sounds like you've got it right if you're seeing the Tomcat home page.
Maybe you also want your application to be the default application for that host?

If so, rename your application to "ROOT".
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to change virtual host from http://localhost/test to http://www.fakedomain.com/?