简体   繁体   中英

How to change root directory in Tomcat

I have a web application with name linkpointe in my webapps directory. I would like to create two instances of this application so that I can have different versions running. However, if I place two applications in different directories it does not work - ie

http://localhost:8080/firstApp/linkpointe
http://localhost:8080/secondApp/linkpointe

Also, if I change the name to for example something like linkpointe1 and linkpointe2 it still does not work.

The root needs to be exactly linkpointe in order for the app to work - ie below

//this works
http://localhost:8080/linkpointe

How can I make two instances of the application run on my Tomcat container? Can someone tell me even how to modify the default root of the application and possibly add more, like linkpointe1 and linkpointe2? Thanks for all your help.

Tomcat's appBase directories aren't meant to have sub-directories that aren't webapps in them, so you can't just do

mkdir webapps/fitstApp
cp linkpoint.war webapps/firstApp/linkpoint.war
mkdir webapps/secondApp
cp linkpointe.war webapps/secondApp

Instead, you need to have two separate deployments. If you need two versions of a webapp that must be named "linkpointe", then you will need to have two separate virtual hosts (ie two separate <Host> elements).

Fortunately, each virtual host has its own appBase, so you can copy linkpointe.war into both of those and you should be all set.

How about creating two war files? (linkpointe1.war and linkpointe2.war) Copy the war files to your webapps directory and let tomcat deploy.

You should end up with directories under your webapps dir such as

webapps/linkpointe1
webapps/linkpointe2

Then your URLs will be

http://localhost:8080/linkpointe1
http://localhost:8080/linkpointe2

If it needs to be exactly linkpointe due to dependency within the app the two virtual hosts should work as @christopher stated in his answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM