CentOS6.5上安裝Resin3.1-創(chuàng)新互聯(lián)

1、下載jdk和resin

成都創(chuàng)新互聯(lián)公司長(zhǎng)期為上千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為通渭企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作,通渭網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
[root@mylinux4 ~]# mkdir /opt/tools
[root@mylinux4 ~]# cd /opt/tools/
[root@mylinux4 tools]# wget http://www.caucho.com/download/resin-3.1.13.tar.gz 
[root@mylinux4 tools]# ll
total 80384
-rw-r--r-- 1 root root 72036348 Oct  2 18:35 jdk-6u34-linux-x64.bin
-rw-r--r-- 1 root root 10273075 Oct  2 19:13 resin-3.1.13.tar.gz

(因?yàn)閖dk需要到oracle官網(wǎng)下載,需要登錄oracle賬號(hào),所以就不再說(shuō)明下載過(guò)程了)

2、安裝jdk

[root@mylinux4 tools]# chmod +x jdk-6u34-linux-x64.bin 
[root@mylinux4 tools]# ./jdk-6u34-linux-x64.bin 
[root@mylinux4 tools]# ll
total 87592
-rw-r--r-- 1 root root  7374712 Oct  2 19:30 httpd-2.2.23.tar.gz
drwxr-xr-x 8 root root     4096 Oct  2 19:34 jdk1.6.0_34
-rwxr-xr-x 1 root root 72036348 Oct  2 18:35 jdk-6u34-linux-x64.bin
-rw-r--r-- 1 root root 10273075 Oct  2 19:13 resin-3.1.13.tar.gz
[root@mylinux4 tools]# mkdir -p /usr/local/jdk
[root@mylinux4 tools]# cp -a jdk1.6.0_34/* /usr/local/jdk/
[root@mylinux4 tools]# cd /usr/local/jdk
[root@mylinux4 jdk]# ls
bin        jre      README.html          src.zip
COPYRIGHT  lib      register.html        THIRDPARTYLICENSEREADME.txt
db         LICENSE  register_ja.html
include    man      register_zh_CN.html
[root@mylinux4 jdk]# /usr/local/jdk/bin/java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)

3、配置java環(huán)境變量

[root@mylinux4 jdk]# echo '# Add java env below' >>/etc/profile

[root@mylinux4 jdk]# echo 'export JAVA_HOME=/usr/local/jdk' >>/etc/profile

[root@mylinux4 jdk]# echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >>/etc/profile

[root@mylinux4 jdk]# echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >>/etc/profile

[root@mylinux4 jdk]# echo 'export RESIN_HOME=/usr/local/resin' >>/etc/profile

[root@mylinux4 jdk]# echo '# java env ended' >>/etc/profile

[root@mylinux4 jdk]# tail -6 /etc/profile

# Add java env below

export JAVA_HOME=/usr/local/jdk

export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin

export RESIN_HOME=/usr/local/resin

# java env ended

[root@mylinux4 jdk]# source /etc/profile

處理完成之后,進(jìn)行下面的測(cè)試:

[root@mylinux4 jdk]# java -version

java version "1.6.0_34"

Java(TM) SE Runtime Environment (build 1.6.0_34-b04)

Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)

[root@mylinux4 jdk]# which java

/usr/local/jdk/bin/java

[root@mylinux4 jdk]# echo $JAVA_HOME

/usr/local/jdk

4、安裝resin

[root@mylinux4 jdk]# cd /opt/tools/
[root@mylinux4 tools]# tar -zxf resin-3.1.13.tar.gz 
[root@mylinux4 tools]# ll
total 87596
-rw-r--r--  1 root root  7374712 Oct  2 19:30 httpd-2.2.23.tar.gz
drwxr-xr-x  8 root root     4096 Oct  2 19:34 jdk1.6.0_34
-rwxr-xr-x  1 root root 72036348 Oct  2 18:35 jdk-6u34-linux-x64.bin
drwxr-xr-x 14 root root     4096 Oct  2 20:01 resin-3.1.13
-rw-r--r--  1 root root 10273075 Oct  2 19:13 resin-3.1.13.tar.gz
[root@mylinux4 tools]# cp -a resin-3.1.13 /usr/local/resin

resin如果不和apache配合生成模塊,則不需要編譯。

5、配置resin

[root@mylinux4 tools]# cd /usr/local/resin/conf
[root@mylinux4 conf]# ll
total 48
-rw-r--r-- 1 root root 12216 Nov  9  2012 app-default.xml
-rw-r--r-- 1 root root  3007 Nov  9  2012 development.conf
-rw-r--r-- 1 root root   270 Nov  9  2012 fine.conf
-rw-r--r-- 1 root root   641 Nov  9  2012 minimal.conf
-rw-r--r-- 1 root root  9970 Nov  9  2012 resin.conf
-rw-r--r-- 1 root root  9970 Nov  9  2012 resin.conf.orig

查看一下默認(rèn)配置中的server標(biāo)簽:

[root@mylinux4 conf]# sed -n '88,146p' resin.conf
    <server-default>
      <!-- The http port -->
      <http address="*" port="8080"/>
      <!--
         - SSL port configuration:
         -
         - <http address="*" port="8443">
         -   <openssl>
         -     <certificate-file>keys/gryffindor.crt</certificate-file>
         -     <certificate-key-file>keys/gryffindor.key</certificate-key-file>
         -     <password>test123</password>
         -   </openssl>
         - </http>
        -->
      <!--
         - The JVM arguments
        -->
      <jvm-arg>-Xmx256m</jvm-arg>  
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-Xdebug</jvm-arg>
      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
      <!--
         - Uncomment to enable admin heap dumps
         - <jvm-arg>-agentlib:resin</jvm-arg>
        -->
      <!--
         - arguments for the watchdog process
        -->
      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
      <watchdog-port>6600</watchdog-port>
      <!--
         - Configures the minimum free memory allowed before Resin
         - will force a restart.
        -->
      <memory-free-min>1M</memory-free-min>
      <!-- Maximum number of threads. -->
      <thread-max>256</thread-max>
      <!-- Configures the socket timeout -->
      <socket-timeout>65s</socket-timeout>
      <!-- Configures the keepalive -->
      <keepalive-max>128</keepalive-max>
      <keepalive-timeout>15s</keepalive-timeout>
      <!--
         - If starting bin/resin as root on Unix, specify the user name
         - and group name for the web server user.
         -
         - <user-name>resin</user-name>
         - <group-name>resin</group-name>
        -->
    </server-default>

然后重新配置該標(biāo)簽:

[root@mylinux4 conf]# sed -i '88,146d' resin.conf
[root@mylinux4 conf]# vi resin.conf
[root@mylinux4 conf]# sed -n '87,98p' resin.conf
    <server id='test' address='192.168.100.182' port='6911' watchdog-port="6921">
      <http address="*" port="8080" />
 <jvm-arg>-Xmx256m</jvm-arg>  #大堆大小
 <jvm-arg>-Xss1m</jvm-arg>   #設(shè)置每個(gè)線程的stack大小
 <jvm-arg>-Xdebug</jvm-arg>
 <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
 <memory-free-min>1M</memory-free-min>  #當(dāng)jvm的內(nèi)存小于這個(gè)指定值,resin服務(wù)會(huì)graceful重啟,來(lái)釋放泄露的內(nèi)存空間
 <thread-max>256</thread-max>  #大線程數(shù)量
 <socket-timeout>65s</socket-timeout>  #讀寫(xiě)socket大超時(shí)時(shí)間
 <keepalive-max>128</keepalive-max>  #大長(zhǎng)連接數(shù)量
 <keepalive-timeout>15s</keepalive-timeout>  #長(zhǎng)連接超時(shí)時(shí)間
    </server>

6、啟動(dòng)resin

[root@mylinux4 conf]# /usr/local/resin/bin/httpd.sh -server test start
Resin/3.1.13 started -server 'test' for watchdog at 127.0.0.1:6921
[root@mylinux4 conf]# 
[root@mylinux4 conf]# netstat -lntup |egrep "6911|6921|8080"
tcp        0      0 :::8080                     :::*                        LISTEN      1528/java           
tcp        0      0 ::ffff:192.168.100.182:6911 :::*                        LISTEN      1528/java           
tcp        0      0 ::ffff:127.0.0.1:6921       :::*                        LISTEN      1499/java

7、瀏覽器訪問(wèn)web頁(yè)面

CentOS 6.5上安裝Resin 3.1

這是默認(rèn)的web頁(yè)面,web文件默認(rèn)路徑為安裝目錄下的webapps/ROOT.

[root@mylinux4 contrib]# ll /usr/local/resin/webapps/ROOT/

total 8

-rw-r--r-- 1 root root 1507 Nov  9  2012 index.jsp

drwxr-xr-x 5 root root 4096 Oct  2 21:35 WEB-INF

CentOS 6.5上安裝Resin 3.1

里面第一個(gè)鏈接打開(kāi)是resin文檔頁(yè)面,包含resin安裝以及配置等很多文檔介紹。

CentOS 6.5上安裝Resin 3.1

第二個(gè)鏈接是resin的管理頁(yè)面,resin提供了一個(gè)和haproxy類似的狀態(tài)監(jiān)控頁(yè)面。

要想登錄這個(gè)頁(yè)面,可以在這里注冊(cè),生成賬號(hào)信息,然后將代碼插入到resin的配置文件中,然后重啟服務(wù)即可。

1)首先注冊(cè)一個(gè)賬戶

CentOS 6.5上安裝Resin 3.1

輸入用戶名和密碼,然后提交。

CentOS 6.5上安裝Resin 3.1

這里會(huì)生成一段代碼,將代碼插入到resin.conf中,然后修改resin.conf中一處配置即可。

2)修改resin配置

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

    <!--

      - Administration application /resin-admin

     -->

    <prologue>

     <resin:set var="resin_admin_external" value="false"/> #將這里的false改為true

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

    </prologue>

   </web-app>

 <management path="${resin.root}/admin">

  <user name="admin" password="password" disable="true"/> #將這里的true刪掉,改為空

  <user name="admin" password="En7q3NfDAKtXllISHa6+Ew=="/> #這是上面第一步生成的代碼,只添加這一行即可,默認(rèn)已經(jīng)有<management>標(biāo)簽了

  <resin:if test="${resin.professional}">

   <deploy-service/>

   <jmx-service/>

   <log-service/>

   <xa-log-service/>

  </resin:if>

 </management>

3)重啟resin服務(wù),然后輸入用戶名密碼登錄。

CentOS 6.5上安裝Resin 3.1

CentOS 6.5上安裝Resin 3.1

8、resin啟動(dòng)腳本

在resin的安裝目錄下的conrtib下默認(rèn)有init.resin.in和init.resin-iptables文件,一個(gè)是resin的啟動(dòng)腳本模板,一個(gè)是防火墻的配置,只需要稍微修改一下就可以使用。

[root@mylinux4 contrib]# ll /usr/local/resin/contrib/
total 12
-rw-r--r-- 1 root root 2678 Nov  9  2012 build.xml
-rw-r--r-- 1 root root 1792 Nov  9  2012 init.resin.in
-rw-r--r-- 1 root root 1079 Nov  9  2012 init.resin-iptables
[root@mylinux4 contrib]# vi /usr/local/resin/contrib/init.resin.in
[root@mylinux4 contrib]# cp init.resin.in /etc/init.d/resin
[root@mylinux4 contrib]# chmod +x /etc/init.d/resin 
[root@mylinux4 contrib]# /etc/init.d/resin restart
Stopping resin: .
Starting resin: .
[root@mylinux4 contrib]# netstat -lntup |egrep "6911|6921|8080"
tcp        0      0 :::8080                     :::*                        LISTEN      1665/java           
tcp        0      0 ::ffff:192.168.100.182:6911 :::*                        LISTEN      1665/java           
tcp        0      0 ::ffff:127.0.0.1:6921       :::*                        LISTEN      1640/java

下面是調(diào)整后的腳本內(nèi)容:

[root@mylinux4 contrib]# cat /etc/init.d/resin 
#!/bin/sh
#
# Linux startup script for Resin
# chkconfig: 345 85 15
# description: Resin is a Java Web server.
# processname: wrapper.pl
#
# To install, configure this file as needed and copy init.resin
# to /etc/rc.d/init.d as resin.  Then use "# /sbin/chkconfig resin reset"
#
JAVA_HOME=/usr/local/jdk
RESIN_HOME=/usr/local/resin
export JAVA_HOME RESIN_HOME
JAVA=$JAVA_HOME/bin/java
#
# If you want to start the entire Resin process as a different user,
# set this to the user name.  If you need to bind to a protected port,
# e.g. port 80, you can't use USER, but will need to use bin/resin.
#
USER=
#
# Set to the server id to start
#
SERVER="-server test"
#
ARGS="-resin-home $RESIN_HOME $SERVER"
if test -r /lib/lsb/init-functions; then
  . /lib/lsb/init-functions
else
  log_daemon_msg () {
      if [ -z "$1" ]; then
          return 1
      fi
      if [ -z "$2" ]; then
          echo -n "$1:"
          return
      fi
    
      echo -n "$1: $2"
  }
  
  log_end_msg () {
      [ -z "$1" ] && return 1
      if [ $1 -eq 0 ]; then
        echo " ."
      else
        echo " failed!"
      fi
    
    return $1
  }
fi
case "$1" in
  start)
log_daemon_msg "Starting resin"
if test -n "$USER"; then
    su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start" 1>/dev/null 2>/dev/null
else
    $JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start 1>/dev/null 2>/dev/null
        fi
log_end_msg $?
;;
  stop)
log_daemon_msg "Stopping resin"
if test -n "$USER"; then
    su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop" 1>/dev/null 2>/dev/null
else
    $JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop 1>/dev/null 2>/dev/null
        fi
log_end_msg $?
;;
  restart)
$0 stop
$0 start
;;
  *)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

9、resin加入開(kāi)機(jī)啟動(dòng)項(xiàng)

[root@mylinux4 contrib]# chkconfig --add resin
[root@mylinux4 contrib]# chkconfig resin on
[root@mylinux4 contrib]# chkconfig --list resin
resin          0:off1:off2:on3:on4:on5:on6:off

10、resin日志設(shè)置

resin的日志默認(rèn)保存在安裝目錄下的logs/access.log中,格式如下:

   <access-log path="logs/access.log"

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

      rollover-period="1W"/>

下面是resin日志的一個(gè)示例:

[root@mylinux4 contrib]# tail -f ../logs/access.log

192.168.100.1 - - [02/Oct/2016:21:36:30 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:36:30 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:46:48 +0800] "GET /resin-doc HTTP/1.1" 302 76 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:46:48 +0800] "GET /resin-doc/ HTTP/1.1" 200 15227 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:46:52 +0800] "GET /resin-doc/doc/install.xtp HTTP/1.1" 200 6778 "http://192.168.100.182:8080/resin-doc/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:47:30 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:47:30 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:48:01 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:21:48:01 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

192.168.100.1 - - [02/Oct/2016:22:15:55 +0800] "POST /resin-admin/j_security_check?j_uri=status.php HTTP/1.1" 200 2861 "http://192.168.100.182:8080/resin-admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

新聞標(biāo)題:CentOS6.5上安裝Resin3.1-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://bm7419.com/article32/dcodpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、電子商務(wù)服務(wù)器托管、App開(kāi)發(fā)、搜索引擎優(yōu)化、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化