首页 > 代码库 > resin安装与配置
resin安装与配置
resin安装与配置
介绍下第二种支持java的软件resin
官网地址:caucho.com
有两个版本,一个免费的一个收费的
具体步骤如下:
一、下载和配置jdk
(1)下载JDK(百度搜JDK官网)
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
下载步骤截图如下:
(2)解压JDK安装包
[root@kehuji ~]# cd /usr/local/src
[root@kehuji src]# ls
jdk-8u131-linux-i586.gz
[root@kehuji src]# tar -zxvf jdk-8u131-linux-i586.gz
[root@kehuji src]# ls
jdk1.8.0_131 jdk-8u131-linux-i586.gz
(3)移动jdk1.8.0_131
[root@kehuji src]# mv jdk1.8.0_131 /usr/local/
[root@kehuji src]# cd ..
[root@kehuji local]# ls
bin etc games include jdk1.8.0_131 lib libexec sbin share src
(4)做全局环境变量
[root@kehuji local]# vim /etc/profile.d/java.sh
插入:
JAVA_HOME=/usr/local/jdk1.8.0_131/
JAVA_BIN=/usr/local/jdk1.8.0_131/bin
JRE_HOME=/usr/local/jdk1.8.0_131/jre
PATH=$PATH:/usr/local/jdk1.8.0_131/bin:/usr/local/jdk1.8.0_131/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_131/jre/lib:/usr/local/jdk1.8.0_131/lib:/usr/local/jdk1.8.0_131/jre/lib/charsets.jar
(5)保存并使其生效
[root@kehuji src]# source /etc/profile.d/java.sh
(6)查看java版本
[root@kehuji src]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) Client VM (build 25.131-b11, mixed mode)
二、下载和配置resin
(1)下载resin
[root@kehuji ~]# cd /usr/local/src
[root@kehuji src]# wget http://caucho.com/download/resin-4.0.51.tar.gz
[root@kehuji src]# ls
jdk-8u131-linux-i586.gz resin-4.0.51.tar.gz
(2)解压
[root@kehuji src]# tar -zxvf resin-4.0.51.tar.gz
[root@kehuji src]# ll
total 210408
-rw-r--r-- 1 root root 188105480 Apr 25 05:18 jdk-8u131-linux-i586.gz
drwxr-xr-x 20 root root 4096 Apr 25 05:30 resin-4.0.51
-rw-r--r-- 1 root root 27343255 Mar 2 12:00 resin-4.0.51.tar.gz
(3)编译安装
这是和tomcat不同的地方,resin需要编译
在编译之前先安装gcc,命令:yum intall -y gcc
[root@kehuji resin-4.0.51]# ./configure --prefix=/usr/local/resin --with-java=/usr/local/jdk1.8.0_131/
[root@kehuji resin-4.0.51]# echo $?
0
[root@kehuji resin-4.0.51]# make ##如果这一步报错,请安装gcc,命令:yum intall -y gcc
[root@kehuji resin-4.0.51]# echo $?
0
[root@kehuji resin-4.0.51]# make install
[root@kehuji resin-4.0.51]# echo $?
0
(4)查看生成的resin目录
[root@kehuji resin-4.0.51]# ls /usr/local/resin/
app-inf conf endorsed libexec project-jars webapp-jars
bin doc lib log resin-inf webapps
(5)查看自动生成的启动目录
[root@kehuji resin-4.0.51]# ll /etc/init.d/resin
-rwxr-xr-x 1 root root 3249 Apr 25 05:55 /etc/init.d/resin
(6)启动resin
注意:再启动resin之前最好将tomcat关闭,因为都是启用的java进程
[root@kehuji resin-4.0.51]# /etc/init.d/tomcat stop
[root@kehuji resin-4.0.51]# /etc/init.d/resin start
注:resin在这里跟tomcat不同的地方是它支持restart,而tomcat不支持!
(7)查看resin进程
[root@kehuji resin-4.0.51]# ps aux |grep resin
(8)查看resin监听端口
[root@kehuji resin-4.0.51]# netstat -lnp
# 监听端口:6600 6800 8080
(9)用浏览器访问http://192.168.100.111:8080/测试
三、优化配置resin
(1)编辑resin配置文件(更改域名或者端口)
[root@kehuji resin-4.0.51]# cd /usr/local/resin/
[root@kehuji resin]# ls
app-inf conf endorsed libexec project-jars resin-inf webapp-jars
bin doc lib log resin-data watchdog-data webapps
[root@kehuji resin]# cd conf
[root@kehuji conf]# ls
app-default.xml health.xml licenses resin.xml
cluster-default.xml keys resin.properties
[root@kehuji conf]# vim resin.properties
找到app.http : 8080 改为 app.http : 80
注:要先停止nginx,之前80端口是nginx占用的。
[root@kehuji conf]# /etc/init.d/resin restart
浏览器再次访问http://192.168.100.111/ 不加端口号成功,证明80端口能够访问.
(2)更改域名配置文件
[root@kehuji conf]# vim resin.xml
先找到:
再在id="app"内部找到:
在</host>与<resin:if tst="${resin_doc}">中间插入如下内容:
<host id="www.123.com" root-directory=".">
<web-app id="/" root-directory="/tmp/resin"/>
</host>
截图如下:
[root@kehuji conf]# mkdir /tmp/resin
[root@kehuji conf]# /etc/init.d/resin restart
[root@kehuji conf]# ls /tmp/resin/
WEB-INF
注:先创建目录,后重启resin程序,会在目录下自动生成WEB-INF文件
(3)测试jsp解析
[root@kehuji conf]#vim /tmp/resin/123.jsp
写入:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
保存!
[root@kehuji conf]# curl -x127.0.0.1:8080 www.123.com/123.jsp
或[root@kehuji conf]# curl -x192.168.100.111:8080 www.123.com/123.jsp
结果如下:
[root@kehuji resin]# date
Tue Apr 25 10:22:59 CST 2017
[root@kehuji resin]# curl -x192.168.100.111:8080 www.123.com/123.jsp
<html><body><center>
Now time is: Tue Apr 25 10:23:04 CST 2017
</center></body></html>
[root@kehuji resin]# curl -x127.0.0.1:8080 www.123.com/123.jsp
<html><body><center>
Now time is: Tue Apr 25 10:23:19 CST 2017
</center></body></html>
本文出自 “圣骑士控魔之手” 博客,请务必保留此出处http://wutengfei.blog.51cto.com/10942117/1927778
resin安装与配置