[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
[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
[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
[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标签:
[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> 然后重新配置该标签:
8、resin启动脚本
在resin的安装目录下的conrtib下默认有init.resin.in和init.resin-iptables文件,一个是resin的启动脚本模板,一个是防火墙的配置,只需要稍微修改一下就可以使用。
[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 下面是调整后的脚本内容:
[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加入开机启动项