문제

I use apache tomcat 7 to run a lot ofo virtual hosts on a single machine, I insert a Host tag for every virtual host in server.xml, so I can manage them in a centralized manner.
But now, after adding a lot of host tags, server.xml became so large & I'm seeking for a way to put every virtual host related tags in a separated xml file (exactly same that apache does for httpd.conf & virtual host management). e.g I make a separate xml file for every host & put all of them into a directory & force tomcat to load them!
Any Idea???

도움이 되었습니까?

해결책

The following should work but doesn't due to a Tomcat bug. I've fixed the bug in trunk (r1333827) and 7.0.x (r1333829) and the fix will be included in Tomcat 7.0.28 onwards. I could have sworn that this worked previously. It may be that the xml parser in the JVM has been tightened up at some point and that this will still work with older JVM versions but I haven't tested that.

You can use XML entities - one for each host. For example:

Insert the following just before the <server> element:

<!DOCTYPE server-xml [
  <!ENTITY host1 SYSTEM "host1.txt">
]>

The contents of host1.txt is the host element you want to define:

<Host>
  ...
</Host>

And then you insert this into server.xml inside the <engine> element like this:

<engine ...>
  &host1;
</engine>

Repeat for as many hosts as you need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top