tomcat支持软连接设置

http://www.linuxidc.com/Linux/2011-03/33212.htm


http://hi.baidu.com/zjq588/item/aa459db85f1fddeb4ec7fde2


-------------------------------------------------------------


Shell代码 icon_star.png

  1. ln -s /usr/local/project/uploads [$tomcat_home]/webapps/ROOT



然后,打开tomcat对软连接的支持。


tomcat默认不支持软连接,需要为Context 增加allowLinking="true"。


Tomcat 7/6/5:

Xml代码 icon_star.png

  1. <Context path="/" docBase="ROOT" debug="0" allowLinking="true"/>


Tomcat 4:

Xml代码 icon_star.png

  1. <Context path="/a" docBase="ROOT" debug="0">

  2. <Resources className="org.apache.naming.resources.FileDirContext" allowLinking="true"/>

  3. </Context>



-------------------------------------------------

最近在使用Tomcat开发一个项目,由于特殊原因不能使用IDE自带的Maven或者Web Server环境,因此每次修改都需要copy文件到生产环境,但是当项目文件太多以后每次copy都会很慢,于是就想到使用Linux软连接的方式,但是我在自己的webapp下创建软链接之后总是不能访问,后来发现如果需要使用软链接的话需要修改webapp的一些设置。


具体方法是,在webapp目录下创建META-INF目录,并在其下创建一个context.xml文件,内容如下:


<?xml version="1.0" encoding="UTF-8"?>

<Context path="/myapp" allowLinking="true">

</Context>


然后重新启动Tomcat,一切OK。


---------------------------------------


Tomcat使用软连接的方法

来源: ChinaUnix博客  日期: 2008.09.04 09:10 (共有条评论) 我要评论


Following symbolic links in Tomcat
We have several web applications derived from the same code base and as well as sharing the jars in WEB-INF/lib, we provide set of administration pages to allow users to configure and administer the applications. Until now, we’ve always had to make copies of the admin pages and this has caused us configuration headaches as we try and make sure that all the applications have the latest versions of all the pages.
But now I’ve finally managed to work out how to make Tomcat follow symbolic links―and it’s very easy! All you have to do is add allowLinking="true" to the Context tag in the context.xml file. For Tomcat 5.5 and later, I find the most convenient way is to have a META-INF directory in the web application directory and have a context.xml file in this. Like this all the files to do with the web application are in the same place and copying and deploying is easy. So, my context.xml looks like:
As soon as you restart Tomcat, the change comes into effect and you can share directories between applications or even link to directories outside the web application home directory. If you still using Tomcat 4.x then you can’t use the context.xml in the META-INF directory. Instead you have to put it in the server.xml itself.



你可能感兴趣的:(tomcat)