阿里雲服務器Linux CentOS安裝配置(六)resin多端口配置、安裝、部署
1、下載resin包
http://caucho.com/download/resin-4.0.48.zip
2、解壓
unzip resin-4.0.48.zip -d /etc/
3、啟動resin
/etc/resin-4.0.48/bin/resin.sh start
4、訪問測試
curl 127.0.0.1:8080
5、探索resin啟動
cd /etc/resin-4.0.48/
重啟:bin/resin.sh restart 沒問題
cd bin
再重啟:./resin.sh restart 提示錯誤:Error: Unable to access jarfile ./../lib/resin.jar
開始探索:
1、注釋掉resin.sh的最后一行,並加入下面兩行代碼
echo `pwd`(輸出當前所在目錄)
echo $JAVA_EXE -jar ${RESIN_HOME}/lib/resin.jar $*
2、執行命令:./resin.sh start
輸出:
/etc/resin-4.0.48(當前所在目錄)
java -jar ./../lib/resin.jar start
3、結論:
./../lib/resin.jar = /etc/lib/resin.jar
而resin.jar的實際路徑是:/etc/resin-4.0.48/lib/resin.jar,所有才有:Error: Unable to access jarfile ./../lib/resin.jar
4、返回到/etc/resin-4.0.48目錄,執行bin/resin.sh start
輸出:
java -jar bin/../lib/resin.jar start
/etc/resin-4.0.48
這次:bin/../lib/resin.jar = /etc/resin-4.0.48/lib/resin.jar(看出來沒有,這次指向的resin.jar的路徑是正確的,所以能正常啟動)
5、探索完畢,還原resin.sh
// 上面的配置已經足夠部署項目了,下面我們來安裝一個resin啟動目錄
6、依次執行下面的命令
cd /etc/resin-4.0.48/
不指定jdk時:./configure --prefix=/opt/resin(安裝目錄)
指定jdk時:./configure --prefix=/opt/resin --with-java-home=/usr/lib/jvm/java-1.7.0 --enable-64bit
make
make install
7、啟動
先停止前面啟動的服務:/etc/resin-4.0.48/bin/resin.sh stop
啟動resin:service resin start(安裝后就可以這么啟動了)
訪問下試試:http://ip:8080
查看啟動參數配置:cat -n /etc/init.d/resin
8、添加一個14805端口
進入配置目錄 cd /opt/resin/conf
vi resin.xml
找到下面這段代碼,在它下面拷貝一份
<cluster id="app"> <!-- define the servers in the cluster --> <server-multi id-prefix="app-" address-list="${app_servers}" port="6800"/> <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"/> </host> <resin:if test="${resin_doc}"> <host id="${resin_doc_host}" root-directory="${resin_doc_host}"> <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/> </host> </resin:if> </cluster>
修改為:
<cluster id="llj"> <server-multi id-prefix="llj-" address-list="${llj_servers}" port="6800"/> <host-default> <web-app-deploy path="webapps" expand-preserve-fileset="WEB-INF/work/**" multiversion-routing="${webapp_multiversion_routing}" path-suffix="${elastic_webapp?resin.id:''}"/> </host-default> <host-deploy path="hosts"> <host-default> <resin:import path="host.xml" optional="true"/> </host-default> </host-deploy> <host id="" root-directory="."> <web-app id="/" root-directory="webapps/ROOT"/> </host> </cluster>
配置端口:
vi resin.properties,添加下面兩個屬性
llj.http = 14805 llj_servers = 127.0.0.1:6801
啟動服務:/opt/resin/bin/resin.sh --server llj-0 start
訪問下試試:curl 127.0.0.1:14805
到現在為止,resin上兩個端口8080、14805都啟動好了。它們指向的是同一個應用目錄,你也可以為它們指定不同的應用目錄
9、部署項目
將一個.war文件拷貝到/opt/resin/webapps目錄下,再訪問下兩個端口的服務,顯示的是你項目的首頁,表示部署成功