创建软链接及解决项目内的软链访问报404的问题
来源:互联网 发布:网络市场调研的程序 编辑:程序博客网 时间:2024/05/16 10:30
实例:ln -s /home/gamestat /gamestat
linux下的软链接类似于windows下的快捷方式
ln -s a b 中的 a 就是源文件,b是链接文件名,其作用是当进入b目录,实际上是链接进入了a目录
如上面的示例,当我们执行命令 cd /gamestat/的时候 实际上是进入了 /home/gamestat/
值得注意的是执行命令的时候,应该是a目录已经建立,目录b没有建立。我最开始操作的是也把b目录给建立了,结果就不对了
[root@iZbp1eqd771ku506fyee6yZ storage-sc]# ln -s /data/resource/ueditor ./ueditor
[root@iZbp1eqd771ku506fyee6yZ storage-sc]# ls
config.json controller.jsp index.jsp META-INF ueditor WEB-INF
[root@iZbp1eqd771ku506fyee6yZ storage-sc]# cd ueditor/
特别需要说明的是,我们在项目下创建的软链默认是不能被外界访问的,要解决这个问题我们得修改tomcat的配置文件,但是修改之前,我们得先看看我们的tomcat的版本是多少,如下所示,可以看到我使用的tomcat的版本是9.0.0
[root@dev bin]# ./version.sh
Using CATALINA_BASE: /root/tomcat/server/storage1
Using CATALINA_HOME: /root/tomcat/server/storage1
Using CATALINA_TMPDIR: /root/tomcat/server/storage1/temp
Using JRE_HOME: /home/data/jdk1.8.0_102
Using CLASSPATH: /root/tomcat/server/storage1/bin/bootstrap.jar:/root/tomcat/server/storage1/bin/tomcat-juli.jar
Server version: Apache Tomcat/9.0.0.M10
Server built: Aug 31 2016 15:00:21 UTC
Server number: 9.0.0.0
OS Name: Linux
OS Version: 3.10.0-327.36.3.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_102-b14
JVM Vendor: Oracle Corporation
[root@dev bin]#
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt SESSIONS.ser storage-sc temp webapps work
[root@dev storage1]# cd conf
[root@dev conf]# ls
Catalina catalina.policy catalina.properties context.xml jaspic-providers.xml jaspic-providers.xsd logging.properties server.xml tomcat-users.xml tomcat-users.xsd web.xml
[root@dev conf]#
不同版本的tomcat对context.xml的修改是不一样的,如果是tomcat7及以下版本,那么修改如下,也就是在<Context 后添加了allowLinking="true"这么一句话。
<!-- 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>
如果是tomcat8及其以上版本的话,修改如下,就是在<Context>的下方添加了 一行<Resources allowLinking="true" />,这样就可以访问了!!
<Context>
<Resources allowLinking="true" />
<!-- 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>
删除软链接:
rm -rf b 注意不是rm -rf b/
ln a b 是建立硬链接
建立链接的使用方法如下:
[root@WEB_YQ_64_79 /]# ln --help
Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
or: ln [OPTION]... TARGET (2nd form)
or: ln [OPTION]... TARGET... DIRECTORY (3rd form)
or: ln [OPTION]... -t DIRECTORY TARGET... (4th form)
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
When creating hard links, each TARGET must exist.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-d, -F, --directory allow the superuser to attempt to hard link
directories (note: will probably fail due to
system restrictions, even for the superuser)
-f, --force remove existing destination files
-n, --no-dereference treat destination that is a symlink to a
directory as if it were a normal file
-i, --interactive prompt whether to remove destinations
-s, --symbolic make symbolic links instead of hard links
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY specify the DIRECTORY in which to create
the links
-T, --no-target-directory treat LINK_NAME as a normal file
-v, --verbose print name of each file before linking
--help display this help and exit
--version output version information and exit
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:
none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups
Report bugs to <bug-coreutils@gnu.org>.
- 创建软链接及解决项目内的软链访问报404的问题
- 手机访问本地php项目遇到的问题及解决
- 解决vs2010下不能创建项目及文件的问题
- 创建maven项目出现的问题及解决
- 用struts2框架做项目访问action报找不到action的问题【已解决】
- 关于IDEA 创建WebService实例访问404问题的解决
- Java匿名内部类的创建及访问域
- 解决maven创建项目报错问题
- 在windows上创建软链接解决Dropbox不能同步多个目录的问题
- 跨域访问的解决及问题
- 解决OpenSSL 在VC2015下链接报错的问题。
- 十八招解决winXP局域网内共享访问的问题
- 解决Apache服务器虚拟目录局域网内不能访问的问题
- 局域网内访问tomcat的问题与解决
- 解决Tomcat服务器访问链接数过大的问题
- 解决Tomcat服务器访问链接数过大的问题
- 解决windows 远程桌面链接的问题 3389端口不能访问
- 软链接的创建
- 递归计算a+aa+aaa.....+(n个a)
- Https单向认证和双向认证
- python运算符
- Swift专用流行三方库
- 大数据IMF传奇行动绝密课程第65课:Spark SQL下Parquet深入进阶
- 创建软链接及解决项目内的软链访问报404的问题
- Unity预计算实时GI (二)实时分辨率
- ANDROID 系统网络连接和管理机制与架构
- 【IOS】cocoapods的使用---以AFNetworking为例
- ConcurrentHashMap(2)
- RabbitMq学习笔记(二)—— 工作队列(WorkQueue)
- SpringMVC自定义配置Log4j及其工作原理
- java元注解
- eclipse 小红叉 + ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet