1. 怎样关闭目录浏览方式?
查了些资料,大多数都是说可以 将directory-servlet设置为 “none” 来禁止目录浏览,但是这种方式只是真对于Resin2.x,在3.x中已经不使用directory-servlet了。后来看了下官方的文档资料,原来关闭目录浏览的方法很简单,只需要将resin.conf中
- <servlet servlet-name="directory"
- servlet-class="com.caucho.servlets.DirectoryServlet"/>
注释掉就可以了
2. 设置Servlet为默认首页
在web.xml中这样设置
<servlet-mapping>
<servlet-name>MainPageServlet</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
如果这样的话在Tomcat中可以实现的,但是在Resin中会提示404。后来查了下资料,发现在Resin中默认的首页文件必须真是存在才可以的(”Point is that welcome file MUST exist on the server.”),所以除了上述的设置之外还需要在网站跟目录下面创建一个同名的空文件就可以了。
3. 出现OutOfMemoryException的解决方法
出现OOM异常大多数是因为分配给Resin的内存过小造成的,这个时候可以使用以下命令增大Resin的内存:
- unix> bin/httpd.sh -Xmn100M -Xms500M -Xmx500M
- win> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M
- install win service> bin/httpd.exe -Xmn100M -Xms500M -Xmx500M -install
这样就可以设置Resin使用的内存了
4. Resin和Apache组合
我感觉Resin和Apache组合是最简单的,设置比Tomcat简单方便的多。总结一下可以使用如下步骤:
1) 分别安装Apache和Resin
2) 在Apache中的httpd.conf中添加模块,代码如下:
- LoadModule caucho_module "yourResinHome/win32/apache-2.0/mod_caucho.dll"
3) 如果是同一IP的多个站点,可以将
ResinConfigServer localhost 6802
放到VirtualHost代码中,下面是一个例子:
- <virtualhost *:80>
- ServerName www.3721.com
- DocumentRoot "C:/website/www"
- ResinConfigServer localhost 6802
- </virtualhost>
当然如果想让虚拟站点正确运行的话,还需要在Resin的resin.conf文件中添加站点,具体可以参考Resin手册;如果不是同IP的虚拟站点,只要将 ResinConfigServer localhost 6802 放到任意一个地方就可以了
最后分别重启一下Resin和Apache就可以了,是不是很简单?
参考资料:
Resin 3.0 官方文档