Dict.CN 在线词典, 英语学习, 在线翻译

都市淘沙者

荔枝FM Everyone can be host

统计

留言簿(23)

积分与排名

优秀学习网站

友情连接

阅读排行榜

评论排行榜

apache2与resin 3.1.6 在linux下的整合与负载均衡【转】

<1> 安装apache

./configure --prefix=/opt/apache2 --enable-so  --enable-dav --enable-dav-fs --enable-mods-shared=most  
make
make install
安装resin :
./configure --prefix=/opt/resin3.1.6 --with-apxs=/opt/apache2/bin/apxs  --with-apache=/opt/apache2
make
make install
上述操作编译安装完后,会自动修改apache,包括:
1. copy mod_caucho.so到apache目录(就是前面指定的--with-apache=/data/aoxj/artest/apache)的modules
2. 修改apache的配置文件conf/httpd.conf,自动增加以下内容
LoadModule caucho_module ***/modules/mod_caucho.so
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
如果没有自动修改,请自己手动添加,或者检查,是否配置正确。

1)linux下使用resin的单服务器配置

使用单服务器方案,只要安装完毕,配置一下Resin的resin.conf文件和app_default.xml文件就可以了,resin.conf文件中需要配置两处,
一是端口号,另一处是Web程序存放目录,app_default.xml内可配置默认首页的搜索顺序。
由于原网站使用多个端口配置,所以单服务器只能用于做单个站点的测试使用。
配置如下:
修改resin/conf/resin.conf
 <server id="a" address="192.168.1.116" port="6800"/>
启动 /opt/resin/bin/httpd -server a start
如果使用如下命令默认启动,
/opt/resin/bin/httpd start
必须如下配置.默认 是id 为空
<server id="" address="192.168.1.116" port="6800"/>
启动 /opt/apache2/bin/apachectl start
访问 http://localost/caucho-status 看是否成功.
==========================================================================================================
2)linux下使用resin的多服务器配置

 有时候需要运行多个服务器以在同一个IP上监听多个端口,这时候就需要使用单独的Resin服务器运行多个实例,以监听多个端口来部署多个Web站点。
这种方法为多次使用httpd.sh的参数指定配置文件和运行时的pid文件,实现多个实例的运行。
使用的命令行如下所示:
$RESIN_HOME/bin/httpd.sh -conf conf/resin2.conf -server b start/stop
解释:
 -conf 选项为选择此服务器实例所用的配置文件,在这个文件里面配置不同的端口和主目录。
具体配置如下:
配置一:
copy 一份resin.conf,命名为resin2.conf,找到   <http address="*" port="8080"/>
将其注释掉。修改为: <!--http address="*" port="8080"/-->.
添加<server id="b" address="192.168.1.166" port="6801"/>。
修改apache配置文件 :
LoadModule caucho_module modules/mod_caucho.so
ResinConfigServer 192.168.1.166 6800
ResinConfigServer 192.168.1.166 6801
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
然后用如下命令启动:
/opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin2.conf -server b start
访问 http://localost/caucho-status 看是否成功.

配置二:
copy 一份resin.conf,命名为resin3.conf,找到   <http address="*" port="8080"/>
将其注释掉。修改为: <!--http address="*" port="8080"/-->.
添加
<server id='b' address='192.168.1.166' port='6802' watchdog-port="6602">
  <http port="8081"/>
</server>
这样配置,即启动了两套resin服务。优点是比较安全。缺点是 比较浪费系统资源。
修改apache配置文件 :
LoadModule caucho_module modules/mod_caucho.so
ResinConfigServer 192.168.1.166 6800
ResinConfigServer 192.168.1.166 6802
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
然后用如下命令启动:
/opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin3.conf -server b start
访问 http://localost/caucho-status 看是否成功.
如果访问不了。接着添加如下配置到httpd.conf中。
<Location /caucho-status>
        SetHandler caucho-status
</Location>
============================================================================================================
<2> apache,resin与虚拟主机
上面只是配好apache与resin的整合,其它很多企业应用中还涉及到配置apache与resin的虚拟主机的配置,
接着来说说如何利用apache与resin配置虚拟主机了,注意以下介绍的都是基于一个IP多个域名的虚拟主机的配法:
配置apache2:
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "/www/test1"
    ServerName www.test1.com
    ServerAlias www.test1.com
    ErrorLog "logs/test1_err.log"
    CustomLog "logs/test1_access.log" common
    ResinConfigServer 192.168.1.166 6800
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/www/test2"
    ServerName www.test2.com
    ServerAlias www.test2.com
    ErrorLog "logs/test2_error.log"
    CustomLog "logs/test2_access.log" common
    ResinConfigServer 192.168.1.166 6801
</VirtualHost>
修改apache 配置文件如下:

LoadModule caucho_module modules/mod_caucho.so
ResinConfigServer 192.168.1.166 6800
ResinConfigServer 192.168.1.166 6801
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
<Location /caucho-status>
        SetHandler caucho-status
</Location>
也可以将 第二行和第三行注释掉。

添加目录访问权限:
<Directory "/www">
    Options Indexes FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>
配置resin.conf ,添加如下:
<host id="www.test1.com" root-directory=".">  
    <host-alias>www.test1.com</host-alias>  
    <web-app id="/" root-directory="/www/test1/"></web-app>  
</host>
配置resin2.conf 添加如下内容:
<host id="www.tet2.com" root-directory=".">  
    <host-alias>www.test2.com</host-alias>  
    <web-app id="/" root-directory="/www/test2/"></web-app>  
</host>
注意,<host-alias>一定要和apache中的ServerAlias相对应。
分别启动resin:
/opt/resin3.1.6/bin/httpd.sh -server a start
/opt/resin3.1.6/bin/httpd.sh -conf /opt/resin3.1.6/conf/resin2.conf -server b start
分别在/www/test1和 /www/test2/目录下建立test1.jsp 和test2.jsp测试,是否成功。如果访问成功。
说明配置成功。

以上是不同主机用不同的JVM,如果你只有一个虚拟host的话
可以在Apache的httpd.conf中这么这样设置
<Location /applicationA/*>
ResinConfigServer 192.168.1.166 6800
</Location>
<Location /applicationB/*>
ResinConfigServer 192.168.1.166 6801
</Location>
不同的模块,使用不同的jvm

posted on 2009-07-03 15:37 都市淘沙者 阅读(841) 评论(0)  编辑  收藏 所属分类: Tomcat/Weblogic/Resin/Jboss


只有注册用户登录后才能发表评论。


网站导航: