转自http://467754239.blog.51cto.com/4878013/1558435

一、环境

resin     192.168.1.11

apache     192.168.1.10

二、安装resin

1.安装jdk

#下载软件包
[root@resin ~]# wget http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
[root@resin ~]# tar xf jdk-8u45-linux-x64.tar.gz
[root@resin ~]# cp -r jdk1.8.0_45 /usr/local/

#编辑环境配置文件
[root@resin ~]# cat /etc/profile.d/java.sh
JAVA_HOME=/usr/local/jdk1.8.0_45
JAVA_BIN=$JAVA_HOME/bin
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/jre/lib/charsets.jar

#让环境变量生效
[root@resin ~]# source /etc/profile.d/java.sh

#测试结果
[root@resin ~]# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

2.安装resin

#下载软件包
[root@resin ~]# wget http://www.caucho.com/download/resin-4.0.36.tar.g
[root@resin ~]# tar xf resin-4.0.36.tar.gz 
[root@resin ~]# cd resin-4.0.36
[root@resin resin-4.0.36]# ./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk1.8.0_45/
[root@resin resin-4.0.36]# make && make install

#启动resin
[root@resin resin-4.0.36]# /etc/init.d/resin start
Starting resin: .        
[root@resin resin-4.0.36]# netstat -tunlp |grep java
tcp        0      0 127.0.0.1:6800              0.0.0.0:*                   LISTEN      24545/java          
tcp        0      0 127.0.0.1:6600              0.0.0.0:*                   LISTEN      24503/java          
tcp        0      0 :::8080                     :::*                        LISTEN      24545/java

测试结果

[root@resin ~]# service iptables stop

CentOS 6.4配置resin+apache_CentOS 6.4配置resin+ap

三、简单的resin部署web测试环境

1.创建站点目录和配置文件

#创建站点目录
[root@resin ~]# mkdir -p /webdata/api

#创建站点测试文件
[root@resin ~]# cat /webdata/api/index.jsp
<%@ page language="java" %>
<html>
  <head><title>TomcatA</title></head>
  <body>
    <h1><font color="red">TomcatA </font></h1>
    <table align="centre" border="1">
      <tr>
        <td>Session ID</td>
    <% session.setAttribute("abc","abc"); %>
        <td><%= session.getId() %></td>
      </tr>
      <tr>
        <td>Created on</td>
        <td><%= session.getCreationTime() %></td>
     </tr>
    </table>
  </body>
</html>

2.修改resin配置文件

[root@resin ~]# vim /usr/local/resin/conf/resin.xml
<host id="" root-directory="/webdata">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="api"/>

</host>

3.重启resin服务

[root@resin ~]# /etc/init.d/resin restart

测试结果

CentOS 6.4配置resin+apache_CentOS 6.4配置resin+ap_02

四、resin基于域名和目录的部署

【第一种配置方法】

<!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/ROOT"/>
      <web-app id="/api" root-directory="webapps/api"/>
      <web-app id="/cms1" root-directory="/www/cms1.cdvcloud.com"/>
      <web-app id="/cms2" root-directory="/www/cms2.cdvcloud.com"/>
 
    </host>

【第二种配置方法】

 #第一个appserver
    <host id="www.allentuns.com" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/tset1/ROOT"/>
 
    </host>
    #第二个appserver
        <host id="www.zhengyansheng.com" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/test2/ROOT"/>
 
    </host>

五、resin基于不同端口的部署

[root@Resin ~]# cd /usr/local/resion/conf/
[root@Resin conf]# vim resin.xml 
#只展示重点部分
#注释:Resin默认端口是8080;添加如下代码,在本机配置两个实例端口为8081、8082
<cluster id="app1">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app1" address-list="${app1_servers}" port="6801"/>
 
    <!-- the default host, matching any host name -->
        <host id="" root-directory=".">
              <!--
                            - webapps can be overridden/extended in the resin.xml
                                    -->
      <web-app id="/" root-directory="/var/www/html/app1/ROOT"/>
 
    </host>
    </cluster>
 
<cluster id="app2">
    <!-- define the servers in the cluster -->
    <server-multi id-prefix="app2" address-list="${app2_servers}" port="6802"/>
 
    <!-- the default host, matching any host name -->
        <host id="" root-directory=".">
              <!--
                            - webapps can be overridden/extended in the resin.xml
                                    -->
      <web-app id="/" root-directory="/var/www/html/app2/ROOT"/>
 
    </host>
</cluster>