整合 Resin 和 Apache

本文中使用的 Apache httpd 版本为 2.2.4,Resin 为 OS 3.0.24,操作系统为 Redhat AS 4。
配置步骤如下:
1. 安装 Apache httpd(路径 /usr/local/apache)
输入命令
/usr/local/apache/bin/httpd -l
检查所下载的 Apache httpd 是否支持 DSO 特性。如果以上命令所打印出来的结果中包括 mod_so.c,就表示所安装的 Apache httpd 编译时已经包括了 DSO 特性。否则,需要使用 Apache httpd 的源文件重新编译安装。
1.1. (可选)编译安装 Apache httpd。
进入 Apache httpd 发布包解压缩之后所在的目录,执行命令:
./configure --prefix=/usr/local/apache 
                  --enable-rule=SHARED_CORE 
                  --enable-rule=SHARED_CHAIN 
                  --enable-module=so 
                  --enable-module=most 
                  --enable-shared=max
make
make install

2. 编译 mod_caocho.so
进入 Resin 安装后所在的目录(/usr/local/resin)执行命令:
./configure --with-apxs=/usr/local/apache/bin/apxs
make
完成之后,在 /usr/local/apache/modules 中会生成 mod_caocho.so 文件。

3. 配置环境变量
在 /etc/profile 或者 ~/.profile 中配置
JAVA_HOME =/ usr / local / jdk
RESIN_HOME
=/ usr / local / resin
EXPORT JAVA_HOME RESIN_HOME
保存文件之后执行
source /etc/profile
使得修改在当前终端中即时生效。

4. 配置 srun server
Resin 3.0.24 的默认的 resin.conf 文件中已经配置好 srun server,即如下
< cluster >
  
< srun server-id = ""  host = " 127.0.0.1 "  port = " 6802 " />
</ cluster >

5. 修改根应用的目录
在 resin.conf 中配置
< server >
  
...
  
< host id = "" >
    
< web-app id = ' / ' document-directory = " /usr/local/apache/htdocs " />
  
</ host >
  
...
</ server >

5. 启动 Resin 服务器
$RESIN_HOME/bin/httpd start

6. 配置 Apache httpd.conf
默认情况下,httpd.conf 中会被添加如下内容:
LoadModule caucho_module libexec / mod_caucho . so

ResinConfigServer localhost 
6802
< Location  / caucho-status >
  SetHandler caucho-status
</ Location >
如果文件中没有这些配置,手动添加到 httpd.conf 的底部。

7. 配置虚拟主机
7.1. 一个 JVM 对应多个虚拟主机
此种情况不需要修改 Apache httpd.conf,只需要修改 Resin 的 resin.conf。在 resin.conf 中做如下配置:
< resin xmlns = " http://caucho.com/ns/resin " >
< server >
  
< cluster >
    
< srun id = ""  host = " 127.0.0.1 "  port = " 6802 " />
  
</ cluster >

  
< host id = 'www . domainname1 . com' >
    
< host-alias > domainname1 . com </ host-alias >
    
< root-directory >/ home / httpd / html / domainname1 </ root-directory >
     
...
  
</ host >

  
< host id = 'www . domainname2 . com' >
    
< host-alias > domainname2 . com </ host-alias >
    
< root-directory >/ home / httpd / html / domainname2 </ root-directory >
     
...
  
</ host >
</ server >
</ resin >
7.2. 每个虚拟主机使用一个 JVM
修改 httpd.conf 文件:
< VirtualHost domainname1 . com >
ServerName domainname1
. com
ServerAlias www
. domainname1 . com
ResinConfigServer 
127.0 . 0.1   6802
</ VirtualHost >

< VirtualHost domainname2 . com >
ServerName domainname2
. com
ServerAlias www
. domainname2 . com
ResinConfigServer 
127.0 . 0.1   6803
</ VirtualHost >
在 $RESIN_HOME/conf 中新建 domainname1.conf 文件:
< resin xmlns = " http://caucho.com/ns/resin " >
< server >
  
< cluster >
    
< srun id = ""  host = " 127.0.0.1 "  port = " 6802 " />
  
</ cluster >

  
< host id = 'www . domainname1 . com' >
    
< host-alias > domainname1 . com </ host-alias >
    
< root-directory >/ home / httpd / html / domainname1 </ root-directory >
     
...
  
</ host >
</ server >
新建 domainname2.conf 文件:
< resin xmlns = " http://caucho.com/ns/resin " >
< server >
  
< cluster >
    
< srun id = ""  host = " 127.0.0.1 "  port = " 6803 " />
  
</ cluster >

  
< host id = 'www . domainname2 . com' >
    
< host-alias > domainname2 . com </ host-alias >
    
< root-directory >/ home / httpd / html / domainname2 </ root-directory >
     
...
  
</ host >
</ server >
使用以下命令为每个虚拟主机启动 Resin 服务器:
bin/httpd.sh -pid domainname1.pid -conf conf/domainname1.conf start
bin/httpd.sh -pid domainname2.pid -conf conf/domainname2.conf start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值