在tomcat中发布了个人博客项目
[root@cherishcore ~]# cd /usr/local/tomcat/webapps/
[root@cherishcore webapps]# ls
blog docs host-manager imooc.war ROOT webChat.war ycyt.war
blog.war examples imooc manager webChat ycyt
[root@cherishcore webapps]#
修改conf/server.xml
[root@cherishcore tomcat]# vim + conf/server.xml
在<Host>……<Host>之间加入
<Context docBase="../webapps/blog" path="" debug="0" reloadable="true"/>
如下所示:
<Host name="www.cherishcai.cc" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="../webapps/blog" path="" debug="0" reloadable="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
然后重启tomcat,就行了
或许需要重启两遍以上,个人测试第一次还是tomcat管理页面,第二次重启就行了
欢迎访问个人网站
说到这里,再说一个双开的问题,就是根据不同的域名,做不同的首页
<Host name="www.cherishcai.cc" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="../webapps/blog" path="" debug="0" reloadable="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="www.9918266.cn" appBase="mywebapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="imooc" path="" debug="0" reloadable="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>