Resin,是一個很是流行的application server,對servlet和JSP提供了良好的支持,性能優良,resin自身採用Java語言開發。Resin Pro版本支持緩存和負載均衡。html
1, Resin 下載java
Resin 官方下載網址, 最新版下載 resin-4.0.36.tar.gz(免費版)web
resin 安裝須要提早配置好jdk,下載最新版 JDK7api
(1)Linux環境配置JDK環境變量:瀏覽器
JAVA_HOME=/usr/local/jdk1.6.0_32緩存
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/liboracle
PATH=$PATH:$JAVA_HOME/binapp
export PATH JAVA_HOME CLASSPATH負載均衡
測試java環境:
webapp
[root@test2 conf]# java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.4 20100726 (Red Hat 4.4.4-13)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2, Resin 安裝
(1) 解壓tar.gz
tar zxvf resin-4.0.36.tar.gz
cd resin-4.0.36
(2) 安裝resin
./configure --prefix=/usr/local/resin-4.0.36 --with-java-home=/usr/local/jdk1.6.0_32 --enable-64bit
make
make install
3, Resin 驗證
啓動 resin: ./bin/resin.sh start
開機自啓動: vi /etc/rc.local 添加下行命令:
/usr/local/resin-4.0.36/bin/resin.sh start
[root@test2 bin]# ./resin.sh start
Resin/4.0.36 launching watchdog at 127.0.0.1:6600
Resin/4.0.36 started -server 'app-0' with watchdog at 127.0.0.1:6600
表示 啓動成功
在瀏覽器裏輸入: http://localhost:8080/
點擊resin-admin, 報錯403拒絕
由於我用瀏覽器遠程訪問的,此時須要修改/usr/local/resin-4.0.36/conf 目錄下的 resin.properties 文件,去掉
web_admin_external : true 前面的 ‘#’,就能夠了
出現以上頁面就行了,此時須要註冊管理員帳號
註冊後,默認生成了/usr/local/resin-4.0.36/conf/admin-users.xml.generated
註冊提交後,出現以上頁面,
進入其目錄,把文件admin-users.xml.generated修改成admin-users.xml,能夠看到遠程訪問進行的操做
而後以管理員帳號登錄,出現以上監控頁面
注: 若是部署到無GUI界面的系統上(如 Ubuntu-server、 CentOS、Solaris等),沒法經過瀏覽器訪問本地 resin-admin,則須要修改 resin.properties ,開啓遠程訪問權限:
4, 部署 web
(1)拷貝本身的項目例如:MyPro,到/usr/local/resin-4.0.36/webapps/目錄下
(2) 修改resiin配置文件: vi conf/resin.xml
在節點「host id」下,添加一行「web-app」,指向本身的項目(MyPro),id爲項目的虛擬目錄,例如:api
驗證方法,在瀏覽器裏輸入: http://localhost:8080/api
一.同一個域名下多個子app,根據url層級來指向,例如:
http://www.test.com與http://www.test.com/demo/
二.多個域名對應指定的host,根據域名來指向,例如:
http://www.test1.com與http://www.test2.com
第一種的配置方法:
<cluster id="app">
<!-- define the servers in the cluster -->
<server-multi id-prefix="app-" address-list="${app_servers}" port="6801"/>
<host-default>
<!-- creates the webapps directory for .war expansion -->
<web-app-deploy path="webapps"
expand-preserve-fileset="WEB-INF/work/**"
multiversion-routing="${webapp_multiversion_routing}"
path-suffix="${elastic_webapp?resin.id:''}"/>
</host-default>
<!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
<host-deploy path="hosts">
<host-default>
<resin:import path="host.xml" optional="true"/>
</host-default>
</host-deploy>
<!-- 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="/demo" root-directory="webapps/demo"/>
</host>
</cluster>
<host-default>
<!-- creates the webapps directory for .war expansion -->
<web-app-deploy path="webapps"
expand-preserve-fileset="WEB-INF/work/**"
multiversion-routing="${webapp_multiversion_routing}"
path-suffix="${elastic_webapp?resin.id:''}"/>
</host-default>
<!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
<host-deploy path="hosts">
<host-default>
<resin:import path="host.xml" optional="true"/>
</host-default>
</host-deploy>
<!--每一個host id下也能夠包含多個web-app,參考第一種的配置方法-->
<host id="www.test1.com" root-directory=".">
<web-app id="/" root-directory="webapps/test1/ROOT"/>
</host>
<host id="www.test2.com" root-directory=".">
<web-app id="/" root-directory="webapps/test2/ROOT"/>
</host>
</cluster>