resin 介绍
java语言介绍
java 是一种编程语言,拥有跨平台、面向对象等特性。
java 编程语言是一个简单、面向对象,分布式、解析性、健壮、安全与系统无关,可以移植、高性能、多线程和动态的语言
java 是有sun 公司与1995年5月推出的java面向对象程序设计语言(以下简称java语言)和java平台的总称。
java技术有四方面组成:java编程语言、java类文件类型、java虚拟机(JVM和java应用程序接口(java API)。
java 平台有java虚拟机和java应用编程接口(API)组成。
java分三个体系:
J2SE(java 2 Platform standard edition java平台标准版)
J2EE(java 2 Platform Enterprise edition java平台企业版)
JEME(java 2 Platform micro edition java平台微型版)
sun公司对java编程语言解释是:java编程语言是个简单、面向对象、分布式、解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言。
执行java应用程序必须安装(java runtime environment JRE),JRE内部有一个java虚拟机(JVM),以及一些标准类库,通过JVM的虚拟机才能在电脑系统执行java(java application)应用程序。
java语言程序文编写完以.java为后缀,java编写完后,用开发环境下的编译器编译生成字节码,字节码文件以.class为后缀,Editplus、记事本等都可以用来编写java源程序。
php和java环境应用场合
a、公司会java和php,哪种多,就用哪种环境
b、如果java和php的人都差不多,要求快速上线,需要快速迭代,那就选择php
c、网站规模很大,是一个长期的工程,锁需要的很多服务PHP是暂时没办法负担的,如搜索,php的搜索lucence的版本明显跟不上,这类就用php
e、java仅从语言上说,比php块很多,但从工程上,实际操作当中,java慢很多,因为PHP存在大量的库,是直接进行数据转换之后调用C实现,并且由于代码更加简练,轻量,实质实现当中,比java快
f、开源的java服务器有tomcat,jboss,resin(百度、搜狗、人人网等大网站),Geronimo
g、传统行业,内部系统,CRM,金融,起步型企业 用java居多
h、互联网公司,新兴网站,创业型项目,需要快速快发,人员好招 用PHP居多
商业的java EE服务器有BEA、Weblagic server、oracle server、等等
resin生产环境
resin 是caucho公司的产品,是一个非常流行的支持servlets和jsp的引擎,速度非常快,resin本身包含了一个支持http/1.1的web服务器,虽然它可以显示动态的内容,但是它显示静态内容的能力也非常强、甚至resin也支持php,速度直逼apache、nginx server.许多站点都是用该web服务构建
resin也可以和许多启动的web服务器一起工作,比如Apache、Nginx和IS等,Resin支持servlet 2.3标准和JSP1.2标准,熟悉ASP和PHP的用户发现用Resin来进行JSP编程是一件很容易的事情
resin支持负载均衡,可以增加web节点的可靠性,方法是增加服务器的数量。
resin版本
resin普通版本和pro版本主要的区别是,pro版本支持缓存和负载均衡,pro因为有强大的cache功能,独立作为web服务器处理静态页面性能都可以和apache有一比,但是普通版本独立作为web服务器性能就差一点,当然可以使用apache+resin的方案借助apache的缓存功能提高性能,但是复杂均衡就是普通版不能比的了,resin监听8080端口
缓存功能指的是让客户端浏览器把网站内容缓存到客户端本地
resin部署
安装环境
[root@Resin ~]# uname -r 2.6.32-431.el6.x86_64 [root@Resin ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@Resin ~]#
resin部署前准备
1、更改yum源: wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo yum install tree -y grep keepcache /etc/yum.conf sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf grep keepcache /etc/yum.conf 2、关闭selinux: setenforce 0 #临时生效 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config #永久生效 setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config 3、时间同步 /usr/sbin/ntpdate pool.ntp.org echo '#time sync by gao at 2010-2-1'>>/var/spool/cron/root echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root crontab -l hostname resin cp /etc/hosts /etc/hosts.bak cp /etc/sysconfig/network /etc/sysconfig/network.bak sed -i '$a 10.0.0.3 resin' /etc/hosts sed -i -e '/HOSTNAME=/d' -e '1aHOSTNAME=resin' /etc/sysconfig/network logout
4、resin环境安装
需要的软件: JDK / httpd / resin
mkdir -p /home/lvnian/tools cd /home/lvnian/tools/ rz -y http://httpd.apache.org/download.cgi https://www.java.net/download/jdk6/6u34/promoted/b04/binaries/jdk-6u34-fcs-bin-b04-linux-amd64-19_jul_2012.bin
#安装jdk文件
chmod +x jdk-6u34-linux-x64.bin ./jdk-6u34-linux-x64.bin mkdir -p /application mv jdk1.6.0_34 /application/ ln -s /application/jdk1.6.0_34/ /application/jdk ls -l /application/ /application/jdk/bin/java -h /application/jdk/bin/java -version
5、设置jave变量
cp /etc/profile /etc/profile.bak`date +%F`
echo "#java env start config by gao 2015-9-6" >>/etc/profile echo "export JAVA_HOME=/application/jdk" >>/etc/profile echo "export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib" >>/etc/profile echo "export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin" >>/etc/profile echo "export RESIN_HOME=/application/resin" >>/etc/profile echo "#java env end config by gao 2015-9-6" >>/etc/profile tail -6 /etc/profile source /etc/profile echo $JAVA_HOME echo $CLASSPATH echo $RESIN_HOME =================================================================== 即在/etc/profile中加入下面内容 #java env start config by gao 2015-9-6 export JAVA_HOME=/application/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=/application/resin #java env end config by gao 2015-9-6 ===================================================================
6、安装resin
cd /home/lvnian/tools/ tar zxf resin-3.1.13.tar.gz mv resin-3.1.13 /application/ ln -s /application/resin-3.1.13 /application/resin ll /application/resin mkdir -p /app/logs/resinlog ls -l /application/
7、如果不和apache配合生产模块,则无需编译,直接配置resin即可
无需备份,它本身就已经备份好 resin.conf.orig配置的
删除88到146行,也就是删除默认的server-default模块。
sed -i '88,146d' /application/resin/conf/resin.conf 修改为下面内容 <server id='lvnian' address='10.0.0.3' port='6911' watchdog-port='6921'> <http address="*" port="8080"/> <jvm-arg>-Xmx256m</jvm-arg> <jvm-arg>-Xss1m</jvm-arg> <jvm-arg>-Xdebug</jvm-arg> <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg> <memory-free-min>1M</memory-free-min> <thread-max>256</thread-max> <socket-timeout>65s</socket-timeout> <keepalive-max>128</keepalive-max> <keepalive-timeout>15s</keepalive-timeout> </server>
8、启动resin
启动命令 /application/resin/bin/httpd.sh -server lvnian start 关闭命令 /application/resin/bin/httpd.sh -server lvnian start 其中-server 指定的是修改后的server id。 /application/resin/bin/httpd.sh --help netstat -lntup|egrep "6911|6921|8080"
#8080是web端口 ,如果不需要resin做web,可以关掉这个配置
#6921是watchdog端口
#6911是真正的resin端口,这个必须要起来,将来在apache里就是把请求抛给这个端口解析的
############################################################## [root@Resin conf]# /application/resin/bin/httpd.sh -server lvnian start Resin/3.1.13 started -server 'lvnian' for watchdog at 127.0.0.1:6921 [root@Resin conf]# netstat -lntup|grep java tcp 0 0 :::46753 :::* LISTEN 2322/java tcp 0 0 ::ffff:127.0.0.1:6921 :::* LISTEN 2298/java [root@Resin conf]# netstat -lntup|grep java tcp 0 0 :::8080 :::* LISTEN 2322/java tcp 0 0 ::ffff:10.0.0.3:6911 :::* LISTEN 2322/java tcp 0 0 :::46753 :::* LISTEN 2322/java tcp 0 0 ::ffff:127.0.0.1:6921 :::* LISTEN 2298/java [root@Resin conf]# /application/resin/bin/httpd.sh -server lvnian stop Resin/3.1.13 stopped -server 'lvnian' for watchdog at 127.0.0.1:6921 [root@Resin conf]# [root@Resin conf]# netstat -lntup|grep java [root@Resin conf]# [root@Resin conf]# ps -ef|grep java root 2431 1 1 22:27 pts/2 00:00:02 /application/jdk1.6.0_34/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/application/resin/ -Dresin.root=/application/resin/ -Xrs -Xss256k -Xmx32m -d64 com.caucho.boot.WatchdogManager -server lvnian start root 2456 2431 2 22:27 pts/2 00:00:04 /application/jdk1.6.0_34/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/application/resin/ -Xmx256m -Xss1m -Xdebug -Dcom.sun.management.jmxremote -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/application/resin/ -Dresin.root=/application/resin/ -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/application/resin/ -Dresin.root=/application/resin/ com.caucho.server.resin.Resin --root-directory /application/resin/ -conf /application/resin/conf/resin.conf -socketwait 34087 -server lvnian start root 2511 1560 0 22:30 pts/2 00:00:00 grep java [root@Resin conf]# ##############################################################
9、测试resin部署是否成功
访问:http://10.0.0.3:8080/
#jsp的文件的默认处理路径
ll /application/resin/webapps/ROOT/ echo '99+1=<%=99+1%>' >/application/resin/webapps/ROOT/test.jsp cat /application/resin/webapps/ROOT/test.jsp curl http://10.0.0.3:8080/test.jsp ##################################### [root@Resin conf]# curl http://10.0.0.3:8080/test.jsp 99+1=100 [root@Resin conf]#
注意防火墙问题
10、修改resin自启动脚本
cp /application/resin/contrib/init.resin.in /etc/init.d/resind chmod +x /etc/init.d/resind vim /etc/init.d/resind 对应行修改为下面内容 10 JAVA_HOME=$JAVA_HOME 11 RESIN_HOME=$RESIN_HOME 27 SERVER="-server lvnian"
11、设置开机自启动需求添加的内容,需要在启动脚本/etc/init.d/resind中加入chkconfig 和
description。也就是下面的内容 # chkconfig: 2345 08 92 # description: Starts, stops and saves iptables firewall
12、apache和resin的整合
为什么要整合resin和apache,已经整合的好处如下:
a.动静分离
b.早起的resin、tomcat的http服务不太好
c.早期的resin、tomcat对rewrite和expire功能不太好
##安装相关依赖库 yum install -y zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel ##安装apache cd /home/lvnian/tools/ tar xf httpd-2.2.27.tar.gz cd httpd-2.2.27 ./configure --prefix=/application/apache2.2.27 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make make install ln -s /application/apache2.2.27/ /application/apache ll /application/apache/ =============================================== ##重新编译resin,把resin的mod_caucho.so 模块加到apache中 cd /application/resin-3.1.13/ ./configure --with-apxs=/application/apache2.2.27/bin/apxs cd /application/resin-3.1.13/modules/c/src/ make && make install ll /application/apache/modules/ =============================================== [root@Resin src]# ll /application/apache/modules/ total 180 -rw-r--r--. 1 root root 9115 Sep 6 14:13 httpd.exp -rwxr-xr-x. 1 root root 170883 Sep 6 14:17 mod_caucho.so<=========编译完,多这个模块
提示:这个模块很类似apache+php结合的模块一样,apache就是通过这个mod_caucho.so这个模块调用resin解析java程序的。
##修改apache配置文件
[root@Resin src]# tail -9 /application/apache/conf/httpd.conf # # mod_caucho Resin Configuration # LoadModule caucho_module /application/apache2.2.27/modules/mod_caucho.so <======刚才编译后,resin在http.conf中添加的模块 ResinConfigServer localhost 6800 CauchoConfigCacheDirectory /tmp CauchoStatus yes [root@Resin src]#
上面都是resin在http中的配置文件,是在编译resin的时候,插进http.conf的内容
这个时候去访问10.0.0.3,还是无法正常访问,应为现在apache把请求转发到的是6800端口,但是我们的resin启动的是6911。所以需要修改为6921.
#更改为下面内容
[root@Resin src]# tail -9 /application/apache/conf/httpd.conf # # mod_caucho Resin Configuration # LoadModule caucho_module /application/apache2.2.27/modules/mod_caucho.so ResinConfigServer 10.0.0.3 6911 CauchoConfigCacheDirectory /tmp CauchoStatus yes [root@Resin src]#
重启apache服务即可
/application/apache/bin/apachectl graceful
再访问10.0.0.3 就可出现it works。
如果是请求动态页面
10.0.0.3/test.jsp
这样就会出现
99+1=100
如果现在把java关闭,再去访问 10.0.0.3/test.jsp,就会出现503错误
当一个静态请求来了,apache自己就处理了,如果是动态页面,就转发给resin
###########把客户端的请求全部抛给resin
[root@Resin apache]# tail -6 /application/apache/conf/httpd.conf LoadModule caucho_module /application/apache2.2.27/modules/mod_caucho.so ResinConfigServer 10.0.0.3 6911 CauchoConfigCacheDirectory /tmp SetHandler caucho-request <=======这个参数是主要的 CauchoStatus yes [root@Resin apache]#
把所有的请求向都后抛给resin的参数SetHandler caucho-request。
可以在httpd.conf配置apache全部向后转发,也可以通过标签匹配配置部分转发,或者在http-vhost.conf中配置虚拟主机实现部分向后转发。
在httpd.conf配置apache全部向后转发,只需要下面两个参数。
ResinConfigServer 10.0.0.3 6911
SetHandler caucho-request <=======这个参数是主要的
SetHandler caucho-request是转发的作用,就是由apache代理,然后把业务转发给resin,全部都会往后抛,如果不加此参数,用户访问会走apache,只要jsp等动态程序才走resin。如果增加了,当用户访问所有的请求,都会有apache转发给resin处理,因此,当未加参数时,默认浏览内容为apache的静态服务,故显示It work,增加了sethandler,就处理resin的默认页面Resin Default Home Page。
添加一个虚拟服务,把所以访问该虚拟的所以服务都走resin。
cd /application/apache/conf/extra/ cp httpd-vhosts.conf httpd-vhosts.conf.ori cat >httpd-vhosts.conf<<EOF NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www" DirectoryIndex index.html index.htm index.jsp ServerName www.lvnian.com ErrorLog "logs/lvnian-error_log" CustomLog "logs/lvnian-access_log" common <Directory "/var/www"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> #Resin ResinConfigServer ResinConfigServer 10.0.0.3 6911 SetHandler caucho-request ##如果不要这个参数,那静态的就在/var/www中找,动态的才往resin中找 </VirtualHost> EOF cat httpd-vhosts.conf sed -i 's%#Include conf/extra/httpd-vhosts.conf%Include conf/extra/httpd-vhosts.conf%g' /application/apache/conf/httpd.conf sed -i 's%ResinConfigServer 10.0.0.3 6911%#ResinConfigServer 10.0.0.3 6911%g' /application/apache/conf/httpd.conf sed -i 's%SetHandler caucho-request%#SetHandler caucho-request%g' /application/apache/conf/httpd.conf 修改httpd.conf最后几行为下面内容 [root@Resin ~]# tail -5 /application/apache/conf/httpd.conf LoadModule caucho_module /application/apache2.2.27/modules/mod_caucho.so #ResinConfigServer 10.0.0.3 6911 #SetHandler caucho-request ##这个参数是把所以的请求都抛给resin [root@Resin ~]#echo '99+11=<%=99+11%>' >/var/www/test.jsp
配置resin起过个虚拟主机。多个端口。下面是两个实例
<server id='lvnian01' address='10.0.0.3' port='6911' watchdog-port='6921'> <http address="*" port="8080"/> <jvm-arg>-Xmx256m</jvm-arg> <jvm-arg>-Xss1m</jvm-arg> <jvm-arg>-Xdebug</jvm-arg> <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg> <memory-free-min>1M</memory-free-min> <thread-max>256</thread-max> <socket-timeout>65s</socket-timeout> <keepalive-max>128</keepalive-max> <keepalive-timeout>15s</keepalive-timeout> </server> ================================================================= <server id='lvnian02' address='10.0.0.3' port='6912' watchdog-port='6922'> <http address="*" port="8081"/> <jvm-arg>-Xmx256m</jvm-arg> <jvm-arg>-Xss1m</jvm-arg> <jvm-arg>-Xdebug</jvm-arg> <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg> <memory-free-min>1M</memory-free-min> <thread-max>256</thread-max> <socket-timeout>65s</socket-timeout> <keepalive-max>128</keepalive-max> <keepalive-timeout>15s</keepalive-timeout> </server> ==================================================================
在同一个host目录下添加多一个站点目录
id属性表示该应用的Web路径。如<web-app id='/test'>,表示该应用在Web上访问的时候应该用http://hostname/test/
最简单的如下:
<web-app id="/www/" root-directory="/var/www"/>
添加上面一行,重启resin服务即可,上面一行说明,新添加的站点目录是/var/www ,但是如果要访问这个站点的目录就用的地址是:http://hostname/www/
修改启动脚本
[root@Resin ~]# cat /etc/init.d/resind-m #!/bin/sh # # Linux startup script for Resin # chkconfig: 345 85 15 # description: Resin is a Java Web server. # # 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" # 定义环境变量 . /etc/init.d/functions StartPath='/application/resin/bin/httpd.sh' ResinLog=/app/logs/resinlog [ ! -d $ResinLog ] && mkdir -p $ResinLog resind() { #如果是多个进程真假下下面的配置端即可 for id in lvnian01 lvnian02 do $StartPath -server $id $1 >> $ResinLog/resin_startup.log if [ $? -eq 0 ] then action "$1 $id resin..." /bin/true else action "$1 $id resin..." /bin/failed fi done } case "$1" in start) resind $1 echo "------------------checking---------------------" sleep 10 netstat -lntup |grep "80|69" echo "------------------check over--------------------" ;; stop) resind $1 ;; restart) resind stop resind start ;; *) echo "Usage:$0{start|stop|restart}" esac exit 0 [root@Resin ~]#
####配置http-vhosts启动多个虚拟主机
[root@Resin extra]# vi httpd-vhosts.conf NameVirtualHost *:80 # NameVirtualHost *:801 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www" DirectoryIndex index.html index.htm index.jsp ServerName www.lvnian.com ErrorLog "logs/lvnian-error_log" CustomLog "logs/lvnian-access_log" common <Directory "/var/www"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> #Resin ResinConfigServer ResinConfigServer 10.0.0.3 6911 SetHandler caucho-request </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/blog" DirectoryIndex index.html index.htm index.jsp ServerName blog.lvnian.com ErrorLog "logs/lvnian-error_log" CustomLog "logs/lvnian-access_log" common <Directory "/var/blog"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> #Resin ResinConfigServer ResinConfigServer 10.0.0.3 6912 SetHandler caucho-request </VirtualHost>
####配置resin支持多站点目录
把host-default 模块删除,添加下面的内容。在对应的位置添加
<!--create first virtual host by gao --> <host id="www.lvnian.com" root-directory="/application/resin/webapps"> <host-alias>www.lvnian.org</host-alias> <!-- - configures an explicit root web-app matching the - webapp's ROOT --> <web-app id="/" root-directory="/application/resin/webapps/WWW"> <session-config cookie-domain="etiantian.org" reuse-session-id="true"> <session-timeout>5</session-timeout> <session-max>12000</session-max> </session-config> <servlet-mapping servlet-class="com.caucho.servlets.ResinStatusServlet"> <url-pattern>/resin-status-lvnian.org</url-pattern> <init enable="read"/> </servlet-mapping> <error-page error-code='404' location='/tips/404.html'/> </web-app> <web-app id="/resin-admin-lvnian.org" root-directory="${resin.home}/php/admin"> <character-encoding>utf-8</character-encoding> <prologue> <resin:set var="resin_admin_external" value="false"/> <resin:set var="resin_admin_insecure" value="true"/> </prologue> <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> </security-constraint> </web-app> <stderr-log path='/app/log/resinlog/blog_stderr.log' rollover-period='1W'/> <stdout-log path='/app/log/resinlog/blog_stdoutr.log' rollover-period='1W'/> </host> <!-- ########################################################################## --> <!--create first virtual host by gao --> <host id="blog.lvnian.com" root-directory="/application/resin/webapps"> <host-alias>blog.lvnian.org</host-alias> <!-- - configures an explicit root web-app matching the - webapp's ROOT --> <web-app id="/" root-directory="/application/resin/webapps/BLOG"> <session-config cookie-domain="etiantian.org" reuse-session-id="true"> <session-timeout>5</session-timeout> <session-max>12000</session-max> </session-config> <servlet-mapping servlet-class="com.caucho.servlets.ResinStatusServlet"> <url-pattern>/resin-status-lvnian.org</url-pattern> <init enable="read"/> </servlet-mapping> <error-page error-code='404' location='/tips/404.html'/> </web-app> <web-app id="/resin-admin-lvnian.org" root-directory="${resin.home}/php/admin"> <character-encoding>utf-8</character-encoding> <prologue> <resin:set var="resin_admin_external" value="false"/> <resin:set var="resin_admin_insecure" value="true"/> </prologue> <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> </security-constraint> </web-app> <stderr-log path='/app/log/resinlog/blog_stderr.log' rollover-period='1W'/> <stdout-log path='/app/log/resinlog/blog_stdoutr.log' rollover-period='1W'/> </host> ######################## sed -i "$a 10.0.0.3 blog.lvnian.org www.lvnian.cc " /etc/hosts cat /etc/hosts
这样就可以实现多目录站点了。
####如果想不借用apache,resin直接向外提供服务。可以
<server id='lvnian02' address='10.0.0.3' port='6912' watchdog-port='6922'> <http address="*" port="8081"/> ###把端口号改为80,就可以直接向外提供服务了 <jvm-arg>-Xmx256m</jvm-arg> <jvm-arg>-Xss1m</jvm-arg> <jvm-arg>-Xdebug</jvm-arg> <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg> <memory-free-min>1M</memory-free-min> <thread-max>256</thread-max> <socket-timeout>65s</socket-timeout> <keepalive-max>128</keepalive-max> <keepalive-timeout>15s</keepalive-timeout> </server>
####错误页面优雅显示
<!--create first virtual host by gao --> <host id="www.lvnian.cc" root-directory="/application/resin/webapps"> <host-alias>blog.lvnian.cc</host-alias> <!-- - configures an explicit root web-app matching the - webapp's ROOT --> <web-app id="/" root-directory="/application/resin/webapps/www"> <session-config cookie-domain="etiantian.org" reuse-session-id="true"> <session-timeout>5</session-timeout> <session-max>12000</session-max> </session-config> <servlet-mapping servlet-class="com.caucho.servlets.ResinStatusServlet"> <url-pattern>/resin-status-lvnian.org</url-pattern> <init enable="read"/> </servlet-mapping> <error-page error-code='404' location='/tips/404.html'/> ##########这一行就是错误页面优雅显示的内容 </web-app> <web-app id="/resin-admin-lvnian.org" root-directory="${resin.home}/php/admin"> <character-encoding>utf-8</character-encoding> <prologue> <resin:set var="resin_admin_external" value="false"/> <resin:set var="resin_admin_insecure" value="true"/> </prologue> <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> </security-constraint> </web-app> <stderr-log path='/app/log/resinlog/blog_stderr.log' rollover-period='1W'/> <stdout-log path='/app/log/resinlog/blog_stdoutr.log' rollover-period='1W'/> </host> ####################
错误优雅显示中,需要在设置优雅显示的站点目录下,创建tips/目录。并在在个目录下放置对应的错误代码优雅显示的html文件
如上面站点,则需要安装如下创建
mkdir -p /application/resin/webapps/www/tips echo "404 page">/application/resin/webapps/www/tips/404.html
####配置状态信息页面
更加上面的实例,其实已经配置了,配置的内容如下
<servlet-mapping servlet-class="com.caucho.servlets.ResinStatusServlet"> <url-pattern>/resin-status-lvnian.org</url-pattern> <init enable="read"/> </servlet-mapping>
设置好windows的hosts文件后,直接访问http://www.lvnian.cc/resin-status-lvnian.org就可以看到resin的转态页面了
####配置resin的管控页面
<web-app id="/resin-admin-lvnian.org" root-directory="${resin.home}/php/admin"> <character-encoding>utf-8</character-encoding> <prologue> <resin:set var="resin_admin_external" value="true"/> ###这里要是true,如果不是true,就会出现403错误 <resin:set var="resin_admin_insecure" value="true"/> </prologue> <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> </security-constraint> </web-app>
###接着打开下面网页。注意端口。如果是80端口可以不写,其他的要写
http://blog.lvnian.org/resin-admin-lvnian.org/
页面中输入生成的用户和密码。把出现的内容,放在resin.conf 的对于位置中,我输入用户名lvnian,密码lvnian123,生成的内容如下:
####################################################### <resin xmlns="http://caucho.com"> <management path="admin"> <user name="lvnian" password="XusEXzyE0JsVRFl7p/ho8Q=="/> ... </management> ... </resin> #######################################################
###############在resin.conf中找到<management>模块修改成如下内容
21 <management path="${resin.root}/admin"> 22 <!-- <user name="admin" password="password" disable="true"/> --> 23 <user name="lvnian" password="XusEXzyE0JsVRFl7p/ho8Q==" disable="false"/> 24 <resin:if test="${resin.professional}"> 25 <deploy-service/> 26 <jmx-service/> 27 <log-service/> 28 <xa-log-service/> 29 </resin:if> 30 </management> 注意就是23行内容 23 <user name="lvnian" password="XusEXzyE0JsVRFl7p/ho8Q==" disable="false"/>
上面的name对于的就是我们的用户名。
password对于的就是我们生成的密码;
后面的diable要给我false
在打开http://blog.lvnian.org/resin-admin-lvnian.org/
输入用户名lvnian 密码lvnian123,就可以登录进去管理了
#####日志设置
<stderr-log path='/app/log/resinlog/blog_stderr.log' rollover-period='1W'/> <stdout-log path='/app/log/resinlog/blog_stdoutr.log' rollover-period='1W'/>
上面是记录一周的日志,我们需要把它给我一天
<stderr-log path='/app/log/resinlog/blog_stderr.log' rollover-period='1D'/> <stdout-log path='/app/log/resinlog/blog_stdoutr.log' rollover-period='1D'/>
如果在目录/app/log/resinlog/,看不到有日志。那么就需要下面的步骤
对于的需要要下面指定记录什么级别的日志:
36 <log name="" level="info" path="stdout:" timestamp="[%H:%M:%S.%s] {%{thread}} "/> 37 <log name="" level="info" path="stderr:" timestamp="[%H:%M:%S.%s] {%{thread}} "/>
也可以用下面格式
269 <access-log path="/app/log/resinlog/access.log" 270 archive-format="access-%Y%m%d.log.gz" 271 format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' 272 rollover-size="10mb" 273 rollover-period="1D"/> 274 275 <stdout-log path="/app/log/resinlog/stdout.log" 276 archive-format="stdout-%Y%m%d.log.gz" 277 timestamp="[%Y.%m.%d %H:%M:%S.%s]" 278 rollover-size="10mb" 279 rollover-period="1D"/> 280 <stderr-log path="/app/log/resinlog/stderr.log" 281 archive-format="stderr-%Y%m%d.log.gz" 282 timestamp="[%Y.%m.%d %H:%M:%S.%s]" 283 rollover-size="10mb" 284 rollover-period="1D"/>