阿里云服务器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目录下,再访问下两个端口的服务,显示的是你项目的首页,表示部署成功

10、这里只是简单的配置、部署,集群配置详细后续再讲,打完收工

04-14 10:31