日期:2014-05-16  浏览次数:20753 次

转 apache resin整合
Apache 是一个出色的 http 服务器, 跟resin和tomcat这些web服务器不同,它不能解释动态页面,但作为服务器来解释html、js等静态文件比web服务器有效得多。而且apache还提供多方面的管理。Apache 可以整合resin或tomcat,当作高效又稳定的web server。

0.首先需要想办法搞到mod_caucho.so
1)下载apache2, 解压
2)安装:切换到apache2 目录下
unix> ./configure --prefix=/usr/local/apache --enable-module=so
unix> make
unix> make install
3)切换到 resin 目录下
unix> ./configure --with-apxs=/usr/local/apache/bin/apxs
unix> make
unix> make install
4) 然后就可以在 apache2 的modules 目录下得到 mod_caucho.so了
5) 复制到/etc/httpd/modules 下。


1 配置 Apache(one) + resin (one)
Apache 2.0.55 resin 3.0.19
配置 Apache + resin 当web 服务器要比单独用resin来做web server优秀的多。Resin的帮助文档也提供和Apache整合的资料。
首先,必先确保你的resin 和 Apache可以单独运行。Resin的安装和测试这里省略。Apache的安装非常简单。只需要默认安即可,中间只需要填写你的email。(我安装的是Apache 2.0.55)Apache安装后默认端口是80 。安装好测试http://localhost/, 若安装成功将显示成功测试的页面。确保你的resin 和 Apache可以单独运行后,修改Apache配置文件 conf/httpd.conf ,在后面加上如下一段。

LoadModule caucho_module /usr/local/apache/modules/mod_caucho.so

ResinConfigServer 192.169.100.15 6802

#The ResinConfigServer is used to tell mod_caucho how to contact the backend #Resin server. The backend Resin server tell's mod_caucho which urls should be #dispatched.

<Location /caucho-status>
  SetHandler caucho-status
</Location>

注:&lt;%resin_home%&gt;代表resin安装目录,到时请将具体目录替代它。

这段的意思是为Apache加上一个插件,Apache以LoadModule ****_module语法加载插件。****_module为插件的名字,后面的是插件的文件地址。caucho_module这个插件就是resin提供的,是Apache和resin通讯的中间件,一般放在resin安装目录下的win32/apache-x.x/下(resin 3.0.19),apache-x.x目录一般有多个,你只要选择符合你的acpache版本的就可以。
或者你可以将相应的apache-x.x目录下的mod_caucho.dll文件复制到apche的插件文件夹内(&lt;%apache_home%&gt;/modules/)。然后使用相对路径。如
LoadModule caucho_module modules/mod_caucho.dll
而下一句中“192.169.100.15 ”代表的是resin所在机器的IP,“6802”是默认端口。然后修改resin的配置文件conf/resin.conf。找到这几行:
<cluster>
<server id="" address="192.168.2.10" port="6802"/>
</srun>

如果它们已经被注释,去掉注释符号,且务必要使这里的端口(如: port="6802")与刚才在resin配置文件中的ResinConfigServer 192.169.100.15 6802 这句话里配置的端口一致,如果你没有使用6802这个默认端口的话。192.169.100.15也应该与127.0.0.1相对应,它们都是指resin所在机器的IP,如果resin与apache同在一部机器,且<srunserver-id=""host="127.0.0.1"port="6802">这里使用127.0.0.1那么在ResinConfigServer 192.169.100.15 6802中应该将192.169.100.15改为localhost或127.0.0.1。就是说如果用了具体的IP如192.169.100.15,那么两个地方都要用具体的IP。
配置成功后打开http://localhost/caucho-status 可看到服务器的配置详细结果。
Apache (one)+ resin (one) 工作流程图如下:


这时访问apache就可访问到resin里配置的项目。Apache负责项目里的静态文件,resin则充当jsp/servlet解释服务器。像项目里这样的http://localhost/tianyacity/js/pageFunc.js (或html文件)则默认由apache 来解释,它将在apache里配置的项目和默认访问路径&lt;%apache_home%&gt;/htdocs/里查找http://localhost/tianyacity/js/pageFunc.js这个路径,它不会到resin里配置的项目里查找。所以要在&lt;%apache_home%&gt;/htdocs/里加上这个目录/tianyacity/js/pageFunc.js 又或者在apache配置文件httpd.conf里配置一个项目:

Alias /tianyacity/ "D:/workspace2006/tianyaCity/web/"

<directoryd:=""workspace2006=""tianyacity=""web="">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</directory>

Alias /tianyacity/ 这里的/tianyacity/是访问路径名,与在resin配置的项目tiayacity的访问最好一致。

如果出现了forbidden错误,可以修改(/etc/httpd/conf/httpd.conf)
搜索"User apache" "Group apache"
改为:
User simon
Group simon

*httpd.conf 解析:
http://www.blogjava.net/lyjjq/articles/40489.html

2 配置 Apache(one)+ resin (many)集群
Apache 2.0.55 resin 3.0.19

配置 Apache + resin 集群只需要在Apache(one)+ resin (one)的基础上修改Apache 和 resin的配置文件。

修改Resin 配置文件如下:


<httpserver-id="pan"host="*"port="8010">
<!--
- SSL port configuration:
-
- <http port="8443">
- <openssl>
- <certific