trytete 发表于 2015-6-23 10:24:16

CentOS 6.4配置resin+apache

一、环境

resin   192.168.1.11
apache   192.168.1.10
二、安装resin
1.安装jdk


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#下载软件包
# wget http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
# tar xf jdk-8u45-linux-x64.tar.gz
# cp -r jdk1.8.0_45 /usr/local/

#编辑环境配置文件
# 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

#让环境变量生效
# source /etc/profile.d/java.sh

#测试结果
# 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#下载软件包
# wget http://www.caucho.com/download/resin-4.0.36.tar.g
# tar xf resin-4.0.36.tar.gz
# cd resin-4.0.36
# ./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk1.8.0_45/
# make && make install

#启动resin
# /etc/init.d/resin start
Starting resin: .      
# 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




测试结果

1
# service iptables stop





三、简单的resin部署web测试环境
1.创建站点目录和配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#创建站点目录
# mkdir -p /webdata/api

#创建站点测试文件
# 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配置文件


1
2
3
4
5
6
7
8
# 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服务

1
# /etc/init.d/resin restart




测试结果

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

【第一种配置方法】

1
2
3
4
5
6
7
8
9
10
11
<!-- 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>




【第二种配置方法】


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#第一个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基于不同端口的部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# cd /usr/local/resion/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>








页: [1]
查看完整版本: CentOS 6.4配置resin+apache