resin跟tomcat一样,也是解析jsp网站的,也需要JDK的支持,所以第一步也是安装JDK,安装JDK的方法参考Tomcat中的安装JDK部分。下面介绍安装resin。resin官网,它有两个版本,其中resin是开源免费的,另一个是resinpro是商业版收费的。
进入源码包目录:
[root@linuxidc ~]# cd /usr/local/src
下载安装包:
[root@linuxidc src]# wget 'www.linuxidc.com/resin-4.0.36.tar.gz'
[root@linuxidc src]# ls
resin-4.0.36.tar.gz
解压:
[root@linuxidc src]# tar zxvf resin-4.0.36.tar.gz
进入安装包:
[root@linuxidc src]# cd resin-4.0.36
配置安装路径和JDK的路径:
[root@linuxidc resin-4.0.36]# ./configure --prefix=/usr/local/resin --with-java=/usr/local/jdk1.8.0_31
编译:
[root@linuxidc resin-4.0.36]# make
安装:
[root@linuxidc resin-4.0.36]# make install
查看安装后的文件:
[root@linuxidc resin-4.0.36]# ls /usr/local/resin/
app-inf conf endorsed libexec project-jars webapp-jars
bin doc lib log resin-inf webapps
查看启动脚本:
[root@linuxidc resin-4.0.36]# ls /etc/init.d/resin
/etc/init.d/resin
先停掉Tomcat:
[root@linuxidc resin-4.0.36]# /etc/init.d/tomcat stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8.0_31
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
启动resin:
[root@linuxidc resin-4.0.36]# /etc/init.d/resin start
Starting resin: .
查看进程:
[root@linuxidc resin-4.0.36]# ps aux |grep java
root 3398 13.3 3.4 349504 66812 pts/0 Sl 03:31 0:03 /usr/local/jdk1.8.0_31/bin/java -Dresin.watchdog=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/resin/ -Dresin.root=/usr/local/resin -Xrs -Xss256k -Xmx32m -server com.caucho.boot.WatchdogManager -root-directory /usr/local/resin -conf /usr/local/resin/conf/resin.xml -log-directory /usr/local/resin/log start-all --log-directory /usr/local/resin/log
root 3444 30.4 6.0 640564 117352 pts/0 Sl 03:31 0:06 /usr/local/jdk1.8.0_31/bin/java -Dresin.server=app-0 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.endorsed.dirs=/usr/local/jdk1.8.0_31/jre/lib/endorsed:/usr/local/resin//endorsed:/usr/local/resin/endorsed -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/resin/ -Xss1m -Xmx256m -server com.caucho.server.resin.Resin --root-directory /usr/local/resin -conf /usr/local/resin/conf/resin.xml -server app-0 -socketwait 58146 -root-directory /usr/local/resin -log-directory /usr/local/resin/log start-all --log-directory /usr/local/resin/log
root 3502 0.0 0.0 5980 748 pts/0 S+ 03:31 0:00 grep java
查看端口(默认端口6600,6800,8080):
[root@linuxidc resin-4.0.36]# netstat -lnp |grep java
tcp 0 0 127.0.0.1:6600 0.0.0.0:* LISTEN 3398/java
tcp 0 0 127.0.0.1:6800 0.0.0.0:* LISTEN 3444/java
tcp 0 0 :::8080 :::* LISTEN 3444/java
unix 2 [ ACC ] STREAM LISTENING 15934 3398/java /tmp/.java_pid3398.tmp
在浏览器中输入:192.168.147.140:8080
进入配置文件目录:
[root@linuxidc resin-4.0.36]# cd /usr/local/resin/conf/
查看都有哪些配置文件:
[root@linuxidc conf]# ls
app-default.xml health.xml licenses resin.xml
cluster-default.xml keys resin.properties
配置1:改变端口8080为80:
编辑配置文件:
[root@linuxidc conf]# vim resin.properties
修改app.http :8080为app.http :80
重启:
[root@linuxidc conf]# /etc/init.d/resin stop
Stopping resin: .
[root@linuxidc conf]# /etc/init.d/resin start
Starting resin: .
查看端口:
[root@linuxidc conf]# netstat -lnp |grep java
tcp 0 0 127.0.0.1:6600 0.0.0.0:* LISTEN 4387/java
tcp 0 0 127.0.0.1:6800 0.0.0.0:* LISTEN 4432/java
tcp 0 0 :::80 :::* LISTEN 4432/java
unix 2 [ ACC ] STREAM LISTENING 16890 4387/java /tmp/.java_pid4387.tmp
在浏览器中输入:192.168.11.160(可以加上:80,也可以不加,默认就是80)进行测试。
配置2:配置虚拟主机
创建网站根目录:
[root@linuxidc conf]# mkdir /data/resinweb
编辑配置文件:
[root@linuxidc conf]# vim resin.xml
在cluster模块中增加一台虚拟主机内容如下:
<host root-directory=".">
<web-app root-directory="/data/resinweb"/>
</host>
重启:
[root@linuxidc conf]# /etc/init.d/resin stop
Stopping resin: .
[root@linuxidc conf]# /etc/init.d/resin start
Starting resin: .
在根目录下写点东西:
[root@linuxidc conf]# vim /data/resinweb/1.jsp
<html>
<body>
<center>
Now time is: <%=new java.util.Date()%>
</center>
</body>
</html>
测试一下jsp解析:
[root@linuxidc conf]# curl -xlocalhost:80
<html>
<body>
<center>
Now time is: Sun Mar 12 03:51:05 CST 2017
</center>
</body>
</html>