1. 程式人生 > >resin安裝與配置

resin安裝與配置

resin配置 tomcat jdk java

resin安裝與配置

介紹下第二種支持java的軟件resin

官網地址:caucho.com

有兩個版本,一個免費的一個收費的

具體步驟如下:

一、下載和配置jdk

(1)下載JDK(百度搜JDK官網)

http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

下載步驟截圖如下:

技術分享

技術分享

(2)解壓JDK安裝包

[[email protected] ~]# cd /usr/local/src

[[email protected]

/* */ src]# ls

jdk-8u131-linux-i586.gz

[[email protected] src]# tar -zxvf jdk-8u131-linux-i586.gz

[[email protected] src]# ls

jdk1.8.0_131 jdk-8u131-linux-i586.gz

(3)移動jdk1.8.0_131

[[email protected] src]# mv jdk1.8.0_131 /usr/local/

[[email protected] src]# cd ..

[[email protected]

/* */ local]# ls

bin etc games include jdk1.8.0_131 lib libexec sbin share src

(4)做全局環境變量

[[email protected] 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)保存並使其生效

[[email protected] src]# source /etc/profile.d/java.sh

(6)查看java版本

[[email protected] 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

[[email protected] ~]# cd /usr/local/src

[[email protected] src]# wget http://caucho.com/download/resin-4.0.51.tar.gz

[[email protected] src]# ls

jdk-8u131-linux-i586.gz resin-4.0.51.tar.gz

(2)解壓

[[email protected] src]# tar -zxvf resin-4.0.51.tar.gz

[[email protected] 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

[[email protected] resin-4.0.51]# ./configure --prefix=/usr/local/resin --with-java=/usr/local/jdk1.8.0_131/

[[email protected] resin-4.0.51]# echo $?

0

[[email protected] resin-4.0.51]# make ##如果這一步報錯,請安裝gcc,命令:yum intall -y gcc

[[email protected] resin-4.0.51]# echo $?

0

[[email protected] resin-4.0.51]# make install

[[email protected] resin-4.0.51]# echo $?

0

(4)查看生成的resin目錄

[[email protected] 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)查看自動生成的啟動目錄

[[email protected] 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進程

[[email protected] resin-4.0.51]# /etc/init.d/tomcat stop

[[email protected] resin-4.0.51]# /etc/init.d/resin start

註:resin在這裏跟tomcat不同的地方是它支持restart,而tomcat不支持!

(7)查看resin進程

[[email protected] resin-4.0.51]# ps aux |grep resin

(8)查看resin監聽端口

[[email protected] resin-4.0.51]# netstat -lnp

# 監聽端口:6600 6800 8080

(9)用瀏覽器訪問http://192.168.100.111:8080/測試


三、優化配置resin

(1)編輯resin配置文件(更改域名或者端口)

[[email protected] resin-4.0.51]# cd /usr/local/resin/

[[email protected] resin]# ls

app-inf conf endorsed libexec project-jars resin-inf webapp-jars

bin doc lib log resin-data watchdog-data webapps

[[email protected] resin]# cd conf

[[email protected] conf]# ls

app-default.xml health.xml licenses resin.xml

cluster-default.xml keys resin.properties

[[email protected] conf]# vim resin.properties

找到app.http : 8080 改為 app.http : 80

技術分享

註:要先停止nginx,之前80端口是nginx占用的。

[[email protected] conf]# /etc/init.d/resin restart

瀏覽器再次訪問http://192.168.100.111/ 不加端口號成功,證明80端口能夠訪問.

(2)更改域名配置文件

[[email protected] 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>

截圖如下:

技術分享

[[email protected] conf]# mkdir /tmp/resin

[[email protected] conf]# /etc/init.d/resin restart

[[email protected] conf]# ls /tmp/resin/

WEB-INF

註:先創建目錄,後重啟resin程序,會在目錄下自動生成WEB-INF文件

(3)測試jsp解析

[[email protected] conf]#vim /tmp/resin/123.jsp

寫入:

<html><body><center>

Now time is: <%=new java.util.Date()%>

</center></body></html>

保存!

[[email protected] conf]# curl -x127.0.0.1:8080 www.123.com/123.jsp

或[[email protected] conf]# curl -x192.168.100.111:8080 www.123.com/123.jsp

結果如下:

[[email protected] resin]# date

Tue Apr 25 10:22:59 CST 2017

[[email protected] 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>

[[email protected] 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安裝與配置