概述
1、下载jdk和resin
1
2
3
4
5
6
7
|
[root@mylinux4 ~]
# mkdir /opt/tools
[root@mylinux4 ~]
# cd /opt/tools/
[root@mylinux4 tools]
# wget http://www.caucho.com/download/resin-3.1.13.tar.gz
[root@mylinux4 tools]
# ll
total 80384
-rw-r--r-- 1 root root 72036348 Oct 2 18:35 jdk-6u34-linux-x64.bin
-rw-r--r-- 1 root root 10273075 Oct 2 19:13 resin-3.1.13.
tar
.gz
|
(因为jdk需要到oracle官网下载,需要登录oracle账号,所以就不再说明下载过程了)
2、安装jdk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@mylinux4 tools]
# chmod +x jdk-6u34-linux-x64.bin
[root@mylinux4 tools]
# ./jdk-6u34-linux-x64.bin
[root@mylinux4 tools]
# ll
total 87592
-rw-r--r-- 1 root root 7374712 Oct 2 19:30 httpd-2.2.23.
tar
.gz
drwxr-xr-x 8 root root 4096 Oct 2 19:34 jdk1.6.0_34
-rwxr-xr-x 1 root root 72036348 Oct 2 18:35 jdk-6u34-linux-x64.bin
-rw-r--r-- 1 root root 10273075 Oct 2 19:13 resin-3.1.13.
tar
.gz
[root@mylinux4 tools]
# mkdir -p /usr/local/jdk
[root@mylinux4 tools]
# cp -a jdk1.6.0_34/* /usr/local/jdk/
[root@mylinux4 tools]
# cd /usr/local/jdk
[root@mylinux4 jdk]
# ls
bin jre README.html src.zip
COPYRIGHT lib register.html THIRDPARTYLICENSEREADME.txt
db LICENSE register_ja.html
include
man
register_zh_CN.html
[root@mylinux4 jdk]
# /usr/local/jdk/bin/java -version
java version
"1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
|
3、配置java环境变量
[root@mylinux4 jdk]# echo '# Add java env below' >>/etc/profile
[root@mylinux4 jdk]# echo 'export JAVA_HOME=/usr/local/jdk' >>/etc/profile
[root@mylinux4 jdk]# echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >>/etc/profile
[root@mylinux4 jdk]# echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >>/etc/profile
[root@mylinux4 jdk]# echo 'export RESIN_HOME=/usr/local/resin' >>/etc/profile
[root@mylinux4 jdk]# echo '# java env ended' >>/etc/profile
[root@mylinux4 jdk]# tail -6 /etc/profile
# Add java env below
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export RESIN_HOME=/usr/local/resin
# java env ended
[root@mylinux4 jdk]# source /etc/profile
处理完成之后,进行下面的测试:
[root@mylinux4 jdk]# java -version
java version "1.6.0_34"
Java(TM) SE Runtime Environment (build 1.6.0_34-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.9-b04, mixed mode)
[root@mylinux4 jdk]# which java
/usr/local/jdk/bin/java
[root@mylinux4 jdk]# echo $JAVA_HOME
/usr/local/jdk
4、安装resin
1
2
3
4
5
6
7
8
9
10
|
[root@mylinux4 jdk]
# cd /opt/tools/
[root@mylinux4 tools]
# tar -zxf resin-3.1.13.tar.gz
[root@mylinux4 tools]
# ll
total 87596
-rw-r--r-- 1 root root 7374712 Oct 2 19:30 httpd-2.2.23.
tar
.gz
drwxr-xr-x 8 root root 4096 Oct 2 19:34 jdk1.6.0_34
-rwxr-xr-x 1 root root 72036348 Oct 2 18:35 jdk-6u34-linux-x64.bin
drwxr-xr-x 14 root root 4096 Oct 2 20:01 resin-3.1.13
-rw-r--r-- 1 root root 10273075 Oct 2 19:13 resin-3.1.13.
tar
.gz
[root@mylinux4 tools]
# cp -a resin-3.1.13 /usr/local/resin
|
resin如果不和apache配合生成模块,则不需要编译。
5、配置resin
1
2
3
4
5
6
7
8
9
|
[root@mylinux4 tools]
# cd /usr/local/resin/conf
[root@mylinux4 conf]
# ll
total 48
-rw-r--r-- 1 root root 12216 Nov 9 2012 app-default.xml
-rw-r--r-- 1 root root 3007 Nov 9 2012 development.conf
-rw-r--r-- 1 root root 270 Nov 9 2012 fine.conf
-rw-r--r-- 1 root root 641 Nov 9 2012 minimal.conf
-rw-r--r-- 1 root root 9970 Nov 9 2012 resin.conf
-rw-r--r-- 1 root root 9970 Nov 9 2012 resin.conf.orig
|
查看一下默认配置中的server标签:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[root@mylinux4 conf]# sed -n '88,146p' resin.conf
<
server-default
>
<!-- The http port -->
<
http
address
=
"*"
port
=
"8080"
/>
<!--
- SSL port configuration:
-
- <http address="*" port="8443">
- <openssl>
- <certificate-file>keys/gryffindor.crt</certificate-file>
- <certificate-key-file>keys/gryffindor.key</certificate-key-file>
- <password>test123</password>
- </openssl>
- </http>
-->
<!--
- The JVM arguments
-->
<
jvm-arg
>-Xmx256m</
jvm-arg
>
<
jvm-arg
>-Xss1m</
jvm-arg
>
<
jvm-arg
>-Xdebug</
jvm-arg
>
<
jvm-arg
>-Dcom.sun.management.jmxremote</
jvm-arg
>
<!--
- Uncomment to enable admin heap dumps
- <jvm-arg>-agentlib:resin</jvm-arg>
-->
<!--
- arguments for the watchdog process
-->
<
watchdog-jvm-arg
>-Dcom.sun.management.jmxremote</
watchdog-jvm-arg
>
<
watchdog-port
>6600</
watchdog-port
>
<!--
- Configures the minimum free memory allowed before Resin
- will force a restart.
-->
<
memory-free-min
>1M</
memory-free-min
>
<!-- Maximum number of threads. -->
<
thread-max
>256</
thread-max
>
<!-- Configures the socket timeout -->
<
socket-timeout
>65s</
socket-timeout
>
<!-- Configures the keepalive -->
<
keepalive-max
>128</
keepalive-max
>
<
keepalive-timeout
>15s</
keepalive-timeout
>
<!--
- If starting bin/resin as root on Unix, specify the user name
- and group name for the web server user.
-
- <user-name>resin</user-name>
- <group-name>resin</group-name>
-->
</
server-default
>
|
然后重新配置该标签:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@mylinux4 conf]
# sed -i '88,146d' resin.conf
[root@mylinux4 conf]
# vi resin.conf
[root@mylinux4 conf]
# sed -n '87,98p' resin.conf
<server
id
=
'test'
address=
'192.168.100.182'
port=
'6911'
watchdog-port=
"6921"
>
<http address=
"*"
port=
"8080"
/>
<jvm-arg>-Xmx256m<
/jvm-arg
>
#最大堆大小
<jvm-arg>-Xss1m<
/jvm-arg
>
#设置每个线程的stack大小
<jvm-arg>-Xdebug<
/jvm-arg
>
<jvm-arg>-Dcom.sun.management.jmxremote<
/jvm-arg
>
<memory-
free
-min>1M<
/memory-free-min
>
#当jvm的内存小于这个指定值,resin服务会graceful重启,来释放泄露的内存空间
<thread-max>256<
/thread-max
>
#最大线程数量
<socket-timeout>65s<
/socket-timeout
>
#读写socket最大超时时间
<keepalive-max>128<
/keepalive-max
>
#最大长连接数量
<keepalive-timeout>15s<
/keepalive-timeout
>
#长连接超时时间
<
/server
>
|
6、启动resin
1
2
3
4
5
6
7
|
[root@mylinux4 conf]
# /usr/local/resin/bin/httpd.sh -server test start
Resin
/3
.1.13 started -server
'test'
for
watchdog at 127.0.0.1:6921
[root@mylinux4 conf]
#
[root@mylinux4 conf]
# netstat -lntup |egrep "6911|6921|8080"
tcp 0 0 :::8080 :::* LISTEN 1528
/java
tcp 0 0 ::ffff:192.168.100.182:6911 :::* LISTEN 1528
/java
tcp 0 0 ::ffff:127.0.0.1:6921 :::* LISTEN 1499
/java
|
7、浏览器访问web页面
这是默认的web页面,web文件默认路径为安装目录下的webapps/ROOT.
[root@mylinux4 contrib]# ll /usr/local/resin/webapps/ROOT/
total 8
-rw-r--r-- 1 root root 1507 Nov 9 2012 index.jsp
drwxr-xr-x 5 root root 4096 Oct 2 21:35 WEB-INF
里面第一个链接打开是resin文档页面,包含resin安装以及配置等很多文档介绍。
第二个链接是resin的管理页面,resin提供了一个和haproxy类似的状态监控页面。
要想登录这个页面,可以在这里注册,生成账号信息,然后将代码插入到resin的配置文件中,然后重启服务即可。
1)首先注册一个账户
输入用户名和密码,然后提交。
这里会生成一段代码,将代码插入到resin.conf中,然后修改resin.conf中一处配置即可。
2)修改resin配置
<web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
<!--
- Administration application /resin-admin
-->
<prologue>
<resin:set var="resin_admin_external" value="false"/> #将这里的false改为true
<resin:set var="resin_admin_insecure" value="true"/>
</prologue>
</web-app>
<management path="${resin.root}/admin">
<user name="admin" password="password" disable="true"/> #将这里的true删掉,改为空
<user name="admin" password="En7q3NfDAKtXllISHa6+Ew=="/> #这是上面第一步生成的代码,只添加这一行即可,默认已经有<management>标签了
<resin:if test="${resin.professional}">
<deploy-service/>
<jmx-service/>
<log-service/>
<xa-log-service/>
</resin:if>
</management>
3)重启resin服务,然后输入用户名密码登录。
8、resin启动脚本
在resin的安装目录下的conrtib下默认有init.resin.in和init.resin-iptables文件,一个是resin的启动脚本模板,一个是防火墙的配置,只需要稍微修改一下就可以使用。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@mylinux4 contrib]
# ll /usr/local/resin/contrib/
total 12
-rw-r--r-- 1 root root 2678 Nov 9 2012 build.xml
-rw-r--r-- 1 root root 1792 Nov 9 2012 init.resin.
in
-rw-r--r-- 1 root root 1079 Nov 9 2012 init.resin-iptables
[root@mylinux4 contrib]
# vi /usr/local/resin/contrib/init.resin.in
[root@mylinux4 contrib]
# cp init.resin.in /etc/init.d/resin
[root@mylinux4 contrib]
# chmod +x /etc/init.d/resin
[root@mylinux4 contrib]
# /etc/init.d/resin restart
Stopping resin: .
Starting resin: .
[root@mylinux4 contrib]
# netstat -lntup |egrep "6911|6921|8080"
tcp 0 0 :::8080 :::* LISTEN 1665
/java
tcp 0 0 ::ffff:192.168.100.182:6911 :::* LISTEN 1665
/java
tcp 0 0 ::ffff:127.0.0.1:6921 :::* LISTEN 1640
/java
|
下面是调整后的脚本内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
[root@mylinux4 contrib]
# cat /etc/init.d/resin
#!/bin/sh
#
# Linux startup script for Resin
# chkconfig: 345 85 15
# description: Resin is a Java Web server.
# processname: wrapper.pl
#
# To install, configure this file as needed and copy init.resin
# to /etc/rc.d/init.d as resin. Then use "# /sbin/chkconfig resin reset"
#
JAVA_HOME=
/usr/local/jdk
RESIN_HOME=
/usr/local/resin
export
JAVA_HOME RESIN_HOME
JAVA=$JAVA_HOME
/bin/java
#
# If you want to start the entire Resin process as a different user,
# set this to the user name. If you need to bind to a protected port,
# e.g. port 80, you can't use USER, but will need to use bin/resin.
#
USER=
#
# Set to the server id to start
#
SERVER=
"-server test"
#
ARGS=
"-resin-home $RESIN_HOME $SERVER"
if
test
-r
/lib/lsb/init-functions
;
then
.
/lib/lsb/init-functions
else
log_daemon_msg () {
if
[ -z
"$1"
];
then
return
1
fi
if
[ -z
"$2"
];
then
echo
-n
"$1:"
return
fi
echo
-n
"$1: $2"
}
log_end_msg () {
[ -z
"$1"
] &&
return
1
if
[ $1 -
eq
0 ];
then
echo
" ."
else
echo
" failed!"
fi
return
$1
}
fi
case
"$1"
in
start)
log_daemon_msg
"Starting resin"
if
test
-n
"$USER"
;
then
su
$USER -c
"$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start"
1>
/dev/null
2>
/dev/null
else
$JAVA -jar $RESIN_HOME
/lib/resin
.jar $ARGS start 1>
/dev/null
2>
/dev/null
fi
log_end_msg $?
;;
stop)
log_daemon_msg
"Stopping resin"
if
test
-n
"$USER"
;
then
su
$USER -c
"$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop"
1>
/dev/null
2>
/dev/null
else
$JAVA -jar $RESIN_HOME
/lib/resin
.jar $ARGS stop 1>
/dev/null
2>
/dev/null
fi
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
*)
echo
"Usage: $0 {start|stop|restart}"
exit
1
esac
exit
0
|
9、resin加入开机启动项
1
2
3
4
|
[root@mylinux4 contrib]
# chkconfig --add resin
[root@mylinux4 contrib]
# chkconfig resin on
[root@mylinux4 contrib]
# chkconfig --list resin
resin 0:off1:off2:on3:on4:on5:on6:off
|
10、resin日志设置
resin的日志默认保存在安装目录下的logs/access.log中,格式如下:
<access-log path="logs/access.log"
format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
rollover-period="1W"/>
下面是resin日志的一个示例:
[root@mylinux4 contrib]# tail -f ../logs/access.log
192.168.100.1 - - [02/Oct/2016:21:36:30 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:36:30 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:46:48 +0800] "GET /resin-doc HTTP/1.1" 302 76 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:46:48 +0800] "GET /resin-doc/ HTTP/1.1" 200 15227 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:46:52 +0800] "GET /resin-doc/doc/install.xtp HTTP/1.1" 200 6778 "http://192.168.100.182:8080/resin-doc/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:47:30 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:47:30 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:48:01 +0800] "GET /resin-admin HTTP/1.1" 302 78 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:21:48:01 +0800] "GET /resin-admin/ HTTP/1.1" 200 2786 "http://192.168.100.182:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
192.168.100.1 - - [02/Oct/2016:22:15:55 +0800] "POST /resin-admin/j_security_check?j_uri=status.php HTTP/1.1" 200 2861 "http://192.168.100.182:8080/resin-admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
最后
以上就是执着朋友为你收集整理的CentOS 6.5上安装Resin 3.1的全部内容,希望文章能够帮你解决CentOS 6.5上安装Resin 3.1所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复