Linux 安裝Resin4.0.40

轉載自:https://blog.51cto.com/467754239/1558435


一、Resin簡介

Resin官網地址:http://caucho.com/

Resin源碼包下載地址:http://caucho.com/products/resin/download

 

Resin是CAUCHO公司的產品,是一個非常流行的支持servlets和jsp的引擎,速度非常快。

Resin本身包含了一個支持HTTP/1.1的WEB服務器。雖然它可以顯示動態內容,但是它顯示靜態內容的能力也非常強,速度直逼APACHESERVER。許多站點都是使用該WEB服務器構建的

Resin也可以和許多其他的WEB服務器一起工作,比如Apache server和IIS等。Resin支持Servlets 2.3標準和JSP 1.2標準。熟悉ASP和PHP的用戶可以發現用Resin來進行JSP編程是件很容易的事情

Resin支持負載平衡(Load balancing),可以增加WEB站點的可靠性。方法是增加服務器的數量。比如一臺SERVER的錯誤率是1%的話,那麼支持負載平衡的兩個Resin服務器就可以使錯誤率降到0.01%

 

版本區別

resin 普通版本和pro版本主要區別是 pro支持緩存和負載均衡。pro因爲有強大的cache功能,獨立作爲web服務器處理靜態頁面性能都可以和apache有一比。但普通版本獨立作爲web服務器性能就要差一些。當然可以使用apache+resin的方案藉助apache的緩存功能提高性能。 但負載均衡就是普通版不能比的了。

 

二、部署的平臺

[root@Resin src]# uname -r

2.6.32-358.el6.x86_64[root@Resin src]# cat /etc/centos-release

CentOS release 6.4 (Final)[root@Resin src]# uname -r

2.6.32-358.el6.x86_64[root@Resin src]# service iptables status

iptables:未運行防火牆。[root@Resin src]# getenforce

Disabled

 

三、Resin的源碼安裝

1、安裝依賴環境JDK

[root@Resin src]# tar xf jdk-7u60-bin-linux-x64-16.tar.gz -C /usr/local/[root@Resin src]# cat > /etc/profile.d/jdk.sh << EOF> JAVA_HOME=/usr/local/jdk1.7.0_60> CLASSPATH=\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib> PATH=\$PATH:\$JAVA_HOME/bin> export PATH JAVA_HOME CLASSPATH> EOF[root@Resin src]# source /etc/profile[root@Resin src]# java -version

java version "1.7.0_60-ea"

Java(TM) SE Runtime Environment (build 1.7.0_60-ea-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

2、編譯Resin

[root@Resin src]# yum -y install gcc gcc-c++ make[root@Resin src]# tar xf resin-pro-4.0.40.tar.gz [root@Resin src]# cd resin-pro-4.0.40[root@Resin resin-pro-4.0.40]# ./configure --prefix=/usr/local/resion --with-java-home=/usr/local/jdk1.7.0_60 --enable-64bit[root@Resin resin-pro-4.0.40]# make && make install

Resin Configuration Summary:

 

  RESIN       : 4.0.40

    home      : /usr/local/resion

    root      : /usr/local/resion

    conf      : /usr/local/resion/conf

    log       : /usr/local/resion/log

    plugins   : common resin_os resin

    init      : /etc/init.d/resin

 

  JAVA_HOME   : /usr/local/jdk1.7.0_60

 

  JNI         : 64-bit

    include       : -I/usr/local/jdk1.7.0_60/include -I/usr/local/jdk1.7.0_60/include/linux

    CFLAGS        : 

    cflags_shlib  : -fpic

    ld_shlib      : gcc

    ldflags_shlib : -shared -fPIC -m64

    libs_shlib    : 

    epoll() for keepalives

 

  OPENSSL     : No OpenSSL has been found

    *** OpenSSL libraries cannot be compiled ***

 

3、啓動Resin服務

#第一種方法啓動[root@Resin ~]# /usr/local/resion/bin/resin.sh start

Resin/4.0.40 launching watchdog at 127.0.0.1:6600

Resin/4.0.40 started -server 'app-0' with watchdog at 127.0.0.1:6600

 

第二種方法啓動[root@Resin ~]# service resin start

4、驗證Resin

[root@Resin ~]# netstat -tnlp |grep java

tcp        0      0 127.0.0.1:6800              0.0.0.0:*                   LISTEN      4338/java           

tcp        0      0 127.0.0.1:6600              0.0.0.0:*                   LISTEN      4292/java           

tcp        0      0 :::8080                     :::*                        LISTEN      4338/java

5、瀏覽器訪問Resin

http://resin-ip:port

5.2 點擊【/resin-admin】進入登陸、註冊頁面;如下圖所示

5.3 由於首次登陸Resin還沒有用戶,所以先註冊一個管理員賬號;如下圖所示

5.4 點擊【Create Configuration File】;如若用戶創建成功,提示如下圖所示

5.5 註冊用戶創建成功後會在/usr/local/resion/conf目錄下生成一個admin-users.xml.generated的模板文件,這個模板不能直接使用,我們需要將其改成爲admin-users.xml文件

[root@Resin ~]# cd /usr/local/resion/conf/

[root@Resin conf]# cp admin-users.xml.generated admin-users.xml

註釋:如果部署到無GUI界面的系統上如:CentOS Solaris Ubuntu-Server等,無法通過瀏覽器訪問本地resin-admin,則需要修改resin.properties文件愛你,開啓遠程訪問權限,然後再次登錄

[root@Resin conf]# vim resin.properties

5.6 首次登陸後的界面如下:

 

四、簡單的Resin部署web測試環境

1、拷貝自已的項目到Resin的webapps目錄下

[root@Resin ~]# mkdir /usr/local/resion/webapps/api[root@Resin ~]# cat /usr/local/resion/webapps/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配置文件

    <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"/>

 

    </host>

3、測試

五、Resin4基於目錄和域名的部署

1、同一個域名下多個子app,根據url層級來指向

http://www.allentuns.com/

http://www.allentuns.com/api1

http://www.allentuns.com/api2

2、多個域名對應指定的host,根據域名來指定

http://www.allentuns.com/

http://www.zhengyansheng.com/

 

【第一種配置方法】

    <!-- 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>

 

六、Resin4基於不同端口的部署

[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>

 

修改當前目錄vim  resin.properties 修改如下內容:

# app-tier Triad servers: app-0 app-1 app-2

app_servers       : 127.0.0.1:6800

app1_servers      : 127.0.0.1:6801

app2_servers      : 127.0.0.1:6802

# Use overrides for individual server control, for example: app-0.http : 8081

app.http           : 8080

app1.http          : 8081

app2.http          : 8082

 

重新啓動Resin服務使其重新加載Resin配置文件

[root@Resin conf]# service resin restart

Stopping resin: .

Starting resin: .

 

查看多端口Resin服務是否啓動

[root@Resin ~]# netstat -tnlp |grep java

tcp        0      0 127.0.0.1:6800              0.0.0.0:*                   LISTEN      2418/java           

tcp        0      0 127.0.0.1:6801              0.0.0.0:*                   LISTEN      2431/java           

tcp        0      0 127.0.0.1:6802              0.0.0.0:*                   LISTEN      2439/java           

tcp        0      0 127.0.0.1:6600              0.0.0.0:*                   LISTEN      2371/java           

tcp        0      0 :::8080                     :::*                        LISTEN      2418/java           

tcp        0      0 :::8081                     :::*                        LISTEN      2431/java           

tcp        0      0 :::8082                     :::*                        LISTEN      2439/java

 

建立Resin測試頁面並訪問頁面

[root@Resin ~]# cat /var/www/html/app1/ROOT/index.jsp <%@ page language="java" %><html>

  <head><title>app1 port 8081</title></head>

  <body>

    <h1><font color="red">app1 port 8081 </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>

[root@Resin ~]# cat /var/www/html/app2/ROOT/index.jsp <%@ page language="java" %><html>

  <head><title>app2 port 8082</title></head>

  <body>

    <h1><font color="red">app2 port 8082 </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>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章