分享

resin4中配置端口和虚拟目录

 面包小屋 2013-12-17
    在JAVA WEB容器大家族中,Resin可以算的上最轻巧最快速的服务器了。我个人非常喜欢在产品开发阶段使用Resin来测试和调试,因为开发阶段需要频繁地重启服务器。在给客户进行产品部署的时候我还是趋向于使用Tomcat,因为tomcat是全部免费的,而且使用者很多,再加上NIO和GZip模式可以优化服务器性能以及tomcat出色的稳定性。

    Resin4可以给不同的Web app分配不同的端口,也就是说Resin4可以同时开启多个端口的服务,这一点是非常赞的,在tomcat中想要实现这个就必须另外再来一份tomcat,配置不同的端口。而Resin4就不需要了,给不同的应用设置好相应的端口就OK了。Resin4有一个全局端口,也就是默认端口,可以在conf/resin.properties文件中,对HTTP元素进行简单的修改,如下:

  1. # Set HTTP and HTTPS ports  
  2. http          : 8080  
  3. #https         : 8443  

    在Resin中创建虚拟目录的方式是修改conf/resin.xml文件,正如我刚刚说的,每一个虚拟目录都是一个Web app,都可以配置独立的端口号。在resin.xml中一个cluster就代表一个端口应用,代码如下:

  1. <cluster id="app">  
  2.     <!-- define the servers in the cluster -->  
  3.     <server-multi id-prefix="app-" address-list="${app_servers}" port="6800" />  
  4.   
  5.     <host-default>  
  6.         <!-- creates the webapps directory for .war expansion -->  
  7.         <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**"  
  8.             multiversion-routing="${webapp_multiversion_routing}" />  
  9.     </host-default>  
  10.   
  11.     <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->  
  12.     <host-deploy path="hosts" />  
  13.   
  14.     <!-- the default host, matching any host name -->  
  15.     <host id="" root-directory=".">  
  16.         <!-- - webapps can be overridden/extended in the resin.xml -->  
  17.         <web-app id="/" root-directory="webapps/ROOT" />  
  18.         <web-app id="/jPress" root-directory="D:\workspace\java\myeclipse10\jPress\WebRoot" />  
  19.   
  20.         <resin:if test="${resin_doc}">  
  21.             <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc" />  
  22.         </resin:if>  
  23.     </host>  
  24. </cluster>  

    这个cluster是web-app的主簇,在其中添加<web-app>标签就可以配置虚拟目录了,这时候这个应用是使用默认端口进行部署的。如果要给这个簇配置特定的端口号,可以在cluster标签第一个元素前面加上<server-default>标签,如下:

  1. <resin xmlns="http:///ns/resin" xmlns:resin="urn:java:com.caucho.resin">  
  2.   
  3.     <cluster-default>  
  4.         <!-- shared configuration across all clusters -->  
  5.         <resin:import path="classpath:META-INF/caucho/app-default.xml" />  
  6.         <resin:import path="${__DIR__}/health.xml" optional="true" />  
  7.     </cluster-default>  
  8.   
  9.     <cluster id="my-cluster">  
  10.         <server-default>  
  11.             <!-- thread limits, JVM config, keepalives, ports, HTTP -->  
  12.             <http port="8083" />  
  13.         </server-default>  
  14.   
  15.         <host id="www.myhost.com" root-directory="hosts/myhost.com">  
  16.             <resin:MovedPermanently regexp="/old-file" target="/new-path" />  
  17.             <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**" />  
  18.             <web-app id="/custom">  
  19.             </web-app>  
  20.         </host>  
  21.     </cluster>  
  22. </resin>  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多