linux ln -s 实现tomcat 中多个项目文件共享

项目A   需要访问项目B 的文件, 可以通过 ln-s 命令 将 A 路径链接到项目B 的路径下。

例如:ln -s /data/project/static-resources/admin/resources ./

当前目录下多了一个文件夹,说明连接成功

软连接创建好,我们怎么删除它呢

正确的删除方式(删除软链接,但不删除实际数据)

rm -rf ./resources

错误的删除方式

rm -rf ./resources/ (这样就会把原来resources下的内容删除)

 

[root@insurance insurance-mall]# service tomcat8 start^C
[root@insurance insurance-mall]# ll
total 60
drwxr-xr-x 3 root root  4096 Jul 16 16:51 css
-rw-r--r-- 1 root root 11799 Aug 23 16:35 detail.html
drwxr-xr-x 2 root root  4096 Jul 16 16:51 fonts
-rw-r--r-- 1 root root  8922 Aug 22 18:08 form.html
drwxr-xr-x 2 root root  4096 Jul 16 16:51 images
-rw-r--r-- 1 root root  1758 Jun 14 13:42 index.html
-rw-r--r-- 1 root root    57 May  9 13:45 index.jsp
drwxr-xr-x 3 root root  4096 Jul 16 16:51 js
-rw-r--r-- 1 root root  2400 Jun 27 16:51 payment.html
-rw-r--r-- 1 root root  2150 Jul 24 16:33 pay-result.html
lrwxrwxrwx 1 root root    38 Aug 24 16:00 resources -> /data/project/insurance-web/resources/
drwxr-xr-x 3 root root  4096 Aug 22 11:47 WEB-INF
[root@insurance insurance-mall]#

连接过来之后, 还需要对tomcat  的 context 进行设置 允许连接访问, 这里踩了一个坑

发现allowLinking 没有生效。

查资料发现,这是 tomcat7 的设置方式, 而我使用的是tomcat8, 正确配置如下

加入  <Resources allowLinking="true"></Resources>
 

<Context>
        <Resources allowLinking="true"></Resources>
    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值