1、下载jdk和resin
成都创新互联公司长期为上千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为通渭企业提供专业的成都网站设计、成都网站制作,通渭网站改版等技术服务。拥有10多年丰富建站经验和众多成功案例,为您定制开发。[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-Xmx256m -Xss1m -Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote 6600 1M 256 65s 128 15s
然后重新配置该标签:
[root@mylinux4 conf]# sed -i '88,146d' resin.conf [root@mylinux4 conf]# vi resin.conf [root@mylinux4 conf]# sed -n '87,98p' resin.conf-Xmx256m #大堆大小-Xss1m #设置每个线程的stack大小-Xdebug -Dcom.sun.management.jmxremote 1M #当jvm的内存小于这个指定值,resin服务会graceful重启,来释放泄露的内存空间256 #大线程数量65s #读写socket大超时时间128 #大长连接数量15s #长连接超时时间
6、启动resin
[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配置
3)重启resin服务,然后输入用户名密码登录。
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加入开机启动项
[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中,格式如下:
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" 另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文名称:CentOS6.5上安装Resin3.1-创新互联
浏览路径:http://njwzjz.com/article/dcodpc.html