轉自http://467754239.blog.51cto.com/4878013/1558435html
1、環境
java
resin 192.168.1.11linux
apache 192.168.1.10web
2、安裝resinapache
1.安裝jdk
vim
#下載軟件包 [root@resin ~]# wget http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz [root@resin ~]# tar xf jdk-8u45-linux-x64.tar.gz [root@resin ~]# cp -r jdk1.8.0_45 /usr/local/ #編輯環境配置文件 [root@resin ~]# cat /etc/profile.d/java.sh JAVA_HOME=/usr/local/jdk1.8.0_45 JAVA_BIN=$JAVA_HOME/bin JRE_HOME=$JAVA_HOME/jre PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/jre/lib/charsets.jar #讓環境變量生效 [root@resin ~]# source /etc/profile.d/java.sh #測試結果 [root@resin ~]# java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
2.安裝resinapi
#下載軟件包 [root@resin ~]# wget http://www.caucho.com/download/resin-4.0.36.tar.g [root@resin ~]# tar xf resin-4.0.36.tar.gz [root@resin ~]# cd resin-4.0.36 [root@resin resin-4.0.36]# ./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk1.8.0_45/ [root@resin resin-4.0.36]# make && make install #啓動resin [root@resin resin-4.0.36]# /etc/init.d/resin start Starting resin: . [root@resin resin-4.0.36]# netstat -tunlp |grep java tcp 0 0 127.0.0.1:6800 0.0.0.0:* LISTEN 24545/java tcp 0 0 127.0.0.1:6600 0.0.0.0:* LISTEN 24503/java tcp 0 0 :::8080 :::* LISTEN 24545/java
測試結果bash
[root@resin ~]# service iptables stop
3、簡單的resin部署web測試環境session
1.建立站點目錄和配置文件oracle
#建立站點目錄 [root@resin ~]# mkdir -p /webdata/api #建立站點測試文件 [root@resin ~]# cat /webdata/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配置文件
[root@resin ~]# vim /usr/local/resin/conf/resin.xml <host id="" root-directory="/webdata"> <!-- - webapps can be overridden/extended in the resin.xml --> <web-app id="/" root-directory="api"/> </host>
3.重啓resin服務
[root@resin ~]# /etc/init.d/resin restart
測試結果
4、resin基於域名和目錄的部署
【第一種配置方法】
<!-- 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>
5、resin基於不一樣端口的部署
[root@Resin ~]# cd /usr/local/resion/conf/ [root@Resin conf]# vim resin.xml #只展現重點部分 #註釋:Resin默認端口是8080;添加以下代碼,在本機配置兩個實例端口爲808一、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>