vlambda博客
学习文章列表

resin 安装 配置 优化 整合apache

本文包括resin安装,Apache与resin整合支持asp,resin4的https支持,resin优化,同一服务器多个resin设置,resin添加oracle连接池等。


resin安装配置

(1) 设置系统环境变量

(2) 部署java环境

(3) 安装resin

(4) 添加业务用户(如:adc)

(5) 修改resin配置文件

(6) 注释掉webapps

(7) 启动与停止

 

(1) 设置系统环境变量

 [root@web1 software]# cat /etc/sysconfig/i18n

#LANG="en_US.UTF-8"

LANG="zh_CN.GB18030"

SYSFONT="latarcyrheb-sun16"

[root@web1 software]#

(2) 部署java环境

 [root@web1 local]# chmod +xjdk-6u10-linux-x64.bin

[root@web1 local]#./jdk-6u10-linux-x64.bin

[root@web1 local]# ln-s jdk1.6.0_10/   java

vi /etc/profile

添加并修改:

#export PATH USERLOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

JAVA_HOME="/usr/local/java"

PATH="/usr/local/java/bin:/usr/local/java/jre/bin:$PATH"

export PATH USERLOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME

(3) 安装resin

 [root@web1 resin-3.1.7a]# ./configure--prefix=/usr/local/resin3

[[email protected]]#  make

[[email protected]]#  make install

(4) 添加业务用户(如:adc)

 [root@web1 ~]# passwd adc

Changing password foruser adc.

New UNIX password:

Retype new UNIXpassword:

passwd: allauthentication tokens updated successfully.

[root@web1 ~]#

[root@web1 local]#chown -R adc:adc resin3

 

(5) 修改resin配置文件

$ vi /usr/local/resin3/conf/resin.conf

    <!-- configures the default host,matching any host name -->

    <host id=""root-directory=".">

      <!--

         - configures an explicit root web-appmatching the

         - webapp's ROOT

        -->

      <web-app id="/"root-directory="webapps/ROOT"/>

      <web-app id="/resin-admin"root-directory="${resin.home}/php/admin">

        <!--

           - Administration application/resin-admin

          -->

        <prologue>

          <resin:set var="resin_admin_external"value="false"/>

          <resin:setvar="resin_admin_insecure" value="true"/>

        </prologue>

      </web-app>

    </host>

使用<!--  -->可以注释掉无用的信息,将以<web-app 开始的行注释掉,如下所示:

      <!--

      <web-app id="/"root-directory="webapps/ROOT"/>

      <web-app id="/resin-admin"root-directory="${resin.home}/php/admin">

          -->

然后再在下面添加新的一行:  

     <web-app id="/"root-directory="/home/adc/mmsgw/web/">

修改后的例子:

    <!-- configures the default host,matching any host name -->

    <host id=""root-directory=".">

      <!--

         - configures an explicit root web-appmatching the

         - webapp's ROOT

        -->

      <!--

      <web-app id="/"root-directory="webapps/ROOT"/>

      <web-app id="/resin-admin"root-directory="${resin.home}/php/admin">

          -->

      <web-app id="/"root-directory="/home/adc/mmsgw/web/">

        <!--

           - Administration application/resin-admin

          -->

        <prologue>

          <resin:setvar="resin_admin_external" value="false"/>

         <resin:set var="resin_admin_insecure"value="true"/>

        </prologue>

      </web-app>

    </host>

(6) 注释掉webapps

原:

      <!-- creates the webapps directory for.war expansion -->

      <web-app-deploypath="webapps"/>

改变后:

      <!-- creates the webapps directory for.war expansion -->

      <!--

      <web-app-deploypath="webapps"/>

      -->

(7) 启动与停止

 [adc@web1 ~]$ id

uid=501(adc)gid=501(adc) groups=501(adc)

[adc@web1 ~]$/usr/local/resin3/bin/httpd.sh start

[adc@web1 ~]$ /usr/local/resin3/bin/httpd.shstop

同一服务器配置多个resin


 [root@web205 conf]# diff resin.conf  resin.conf.bak

90c90

<       <http address="*"port="80"/>

---

>       <http address="*"port="8080"/>

121c121

<      <watchdog-port>6601</watchdog-port>

---

>      <watchdog-port>6600</watchdog-port>

149c149

<     <server id=""address="127.0.0.1" port="6801"/>

---

>     <server id=""address="127.0.0.1" port="6800"/>

[root@web205 conf]#

    

     88    <server-default>

     89      <!-- The http port -->

     90      <http address="*" port="80"/>

    117      <!--

    118         - arguments for the watchdog process

    119        -->

    120      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>

    121      <watchdog-port>6601</watchdog-port>

 

    148    <!-- define the servers in the cluster -->

    149    <server id="" address="127.0.0.1" port="6801"/>

    150

同一resin指定多个目录(/home/sms/ivrmanage,/home/sms/webservice/admin/)

   306 <!--

      <web-app id="/"root-directory="webapps/ROOT"/>

      <web-app id="/resin-admin"root-directory="${resin.home}/php/admin">

        -->

      <web-app id="/uniinfo"root-directory="/home/sms/webservice/admin/">

        <!--

           - Administration application/resin-admin

          -->

        <prologue>

          <resin:setvar="resin_admin_external" value="false"/>

          <resin:setvar="resin_admin_insecure" value="true"/>

        </prologue>

      </web-app>

      <web-app id="/ivr"root-directory="/home/sms/ivrmanage">

        <prologue>

          <resin:setvar="resin_admin_external" value="false"/>

          <resin:setvar="resin_admin_insecure" value="true"/>

        </prologue>

      </web-app>


apache与resion整合支持JSP

)下载j2dsk-1.4.0.i586.bin

      resion-3.0

      apache

)安装

chmod 755j2dsk-1.4.0.i586.bin

./j2dsk-1.4.0.i586.bin

mv j2dsk-1.4.0/usr/java

vi /etc/profile

在最后加上:

unset i

exportJAVA_HOME=/usr/java

exportRESIN_HOME=/home/tramp //resion的安装目录

保存退出

tar xzvfhttpd-2.0.52.tar.gz

cd httpd-2.0.52

./configure--prefix=/usr/local/apache2 --enable-so --enable-rewrite=shared

make;make install

)编译RESION

tar xzvfresion-3.0.tar.gz

cd resion-3.0

./configure--with-apxs=/usr/local/apache2/bin/apxs--with-apache-libexec=/usr/local/apache2/modules--with-apache-conf=/usr/local/apache2/conf

make;make install

vi resion.conf

修改如下:

<document_directory>/usr/local/apache2/htdocs</document>

重启RESIONapache

/sbin/httpd.sh  //resion bin下有个httpd.sh

vi/usr/local/apache2/htdocs/test.jsp

<%=2+2%>

测试页


resin4的https支持

修改配置文件resin.xml

增加watchdog-port

<server-multiid-prefix="app-" address-list="${app_servers}" port="6800" watchdog-port="6601"/>

    107      <web-app id="/"root-directory="/home/mysxt"/>

修改配置文件resin.properties

app_servers      : 127.0.0.1:6801

对外服务端口

app.http          : 8081

app.https         : 80

web.http          : 8081

web.https         : 80

启动

./resin.sh start

Resin/4.0.50 launchingwatchdog at 127.0.0.1:6601

Resin/4.0.50 started-server 'app-0' with watchdog at 127.0.0.1:6601


resin加oracle连接池

    <!--

       - Sample database pool configuration

       -

       - The JDBC name isjava:comp/env/jdbc/test

         <database>

          <jndi-name>jdbc/mysql</jndi-name>

           <drivertype="org.gjt.mm.mysql.Driver">

            <url>jdbc:mysql://localhost:3306/test</url>

             <user></user>

             <password></password>

            </driver>

            <prepared-statement-cache-size>8</prepared-statement-cache-size>

           <max-connections>20</max-connections>

           <max-idle-time>30s</max-idle-time>

          </database>

      -->

       <database>

          <jndi-name>jdbc/misc</jndi-name>

            <drivertype="oracle.jdbc.driver.OracleDriver">

            <url>jdbc:oracle:thin:@211.151.66.89:1521:mesdb</url>

             <user>misc</user>

            <password>PASSWORD</password>

            </driver>

            <prepared-statement-cache-size>8</prepared-statement-cache-size>

           <max-connections>20</max-connections>

           <max-idle-time>30s</max-idle-time>

          </database>

       <database>

          <jndi-name>jdbc/misc0</jndi-name>

            <driver type="oracle.jdbc.driver.OracleDriver">

            <url>jdbc:oracle:thin:@211.151.66.89:1522:mesdb</url>

             <user>misc</user>

            <password>PASSWORD</password>

            </driver>

           <prepared-statement-cache-size>8</prepared-statement-cache-size>

           <max-connections>20</max-connections>

           <max-idle-time>30s</max-idle-time>

          </database>

resin优化实例

httpd.sh

=========

原:

exec $JAVA_EXE -jar${RESIN_HOME}/lib/resin.jar $*

改后:

MEM_ARGS="-Xmn256M-Xms1024M -Xmx1024M"

exec $JAVA_EXE -jar${RESIN_HOME}/lib/resin.jar $MEM_ARGS $*

修改resin.conf

 (1)Xmx

原:

      <jvm-arg>-Xmx256m</jvm-arg>

      <jvm-arg>-Xss1m</jvm-arg>

      <jvm-arg>-Xdebug</jvm-arg>

      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

改后:

      <jvm-arg>-Xmx1024m</jvm-arg>

      <jvm-arg>-Xss1m</jvm-arg>

      <jvm-arg>-Xdebug</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

(2)thread-max

      <!-- Maximum number of threads. -->

      <thread-max>256</thread-max>

      <!-- Maximum number of threads. -->

      <thread-max>500</thread-max>

(3)socket-timeout

可调整的部分:

      <!-- Configures the socket timeout-->

     <socket-timeout>65s</socket-timeout>

(4) keepalive-max

原:

      <!-- Configures the keepalive -->

     <keepalive-max>128</keepalive-max>

     <keepalive-timeout>15s</keepalive-timeout>

改后:

      <!-- Configures the keepalive -->

     <keepalive-max>500</keepalive-max>

     <keepalive-timeout>120s</keepalive-timeout>

*******************************************

resinconf配置

      <jvm-arg>-Xmx256m</jvm-arg>

      <jvm-arg>-Xss1m</jvm-arg>

      <jvm-arg>-Xdebug</jvm-arg>

     <jvm-arg>-XX:PermSize=64M</jvm-arg>

     <jvm-arg>-XX:MaxNewSize=256m</jvm-arg>

      <jvm-arg>-XX:MaxPermSize=256m</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

      <jvm-arg>-Xms512m</jvm-arg>

      <jvm-arg>-Xmx512m</jvm-arg>

      <jvm-arg>-Xss1m</jvm-arg>

     <jvm-arg>-XX:MaxNewSize=128m</jvm-arg>

      <jvm-arg>-XX:PermSize=256M</jvm-arg>

     <jvm-arg>-XX:MaxPermSize=256m</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

#MEM_ARGS="-Xms512m-Xmx512m  -XX:NewRatio=2  -XX:SurvivorRatio=3 -XX:MaxPermSize=256M-XX:PermSize=256M"

关闭access.log日志输出

vi resin.conf

    263       <!--

    264          - With another web server, likeApache, this can be commented out

    265          - because the web server will logthis information.

    266         -->

    267       <access-logpath="logs/access.log"

    268             format='%h %l %u %t "%r"%s %b "%{Referer}i" "%{User-Agent}i"'

    269            rollover-period="1D"/>

    270

    271       <!-- creates the webapps directoryfor .war expansion -->

删除

    267       <access-logpath="logs/access.log"

    268             format='%h %l %u %t "%r"%s %b "%{Referer}i" "%{User-Agent}i"'

    269            rollover-period="1D"/>