本文中使用的 Apache httpd 版本为 2.2.4,Resin 为 OS 3.0.24,操作系统为 Redhat AS 4。
配置步骤如下:
1. 安装 Apache httpd(路径 /usr/local/apache)
输入命令
检查所下载的 Apache httpd 是否支持 DSO 特性。如果以上命令所打印出来的结果中包括 mod_so.c,就表示所安装的 Apache httpd 编译时已经包括了 DSO 特性。否则,需要使用 Apache httpd 的源文件重新编译安装。
1.1. (可选)编译安装 Apache httpd。
进入 Apache httpd 发布包解压缩之后所在的目录,执行命令:
2. 编译 mod_caocho.so
进入 Resin 安装后所在的目录(/usr/local/resin)执行命令:
完成之后,在 /usr/local/apache/modules 中会生成 mod_caocho.so 文件。
3. 配置环境变量
在 /etc/profile 或者 ~/.profile 中配置
保存文件之后执行
使得修改在当前终端中即时生效。
4. 配置 srun server
Resin 3.0.24 的默认的 resin.conf 文件中已经配置好 srun server,即如下
5. 修改根应用的目录
在 resin.conf 中配置
5. 启动 Resin 服务器
6. 配置 Apache httpd.conf
默认情况下,httpd.conf 中会被添加如下内容:
如果文件中没有这些配置,手动添加到 httpd.conf 的底部。
7. 配置虚拟主机
7.1. 一个 JVM 对应多个虚拟主机
此种情况不需要修改 Apache httpd.conf,只需要修改 Resin 的 resin.conf。在 resin.conf 中做如下配置:
7.2. 每个虚拟主机使用一个 JVM
修改 httpd.conf 文件:
在 $RESIN_HOME/conf 中新建 domainname1.conf 文件:
新建 domainname2.conf 文件:
使用以下命令为每个虚拟主机启动 Resin 服务器:
配置步骤如下:
1. 安装 Apache httpd(路径 /usr/local/apache)
输入命令
/usr/local/apache/bin/httpd -l
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
--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
make
3. 配置环境变量
在 /etc/profile 或者 ~/.profile 中配置
JAVA_HOME
=/
usr
/
local
/
jdk
RESIN_HOME =/ usr / local / resin
EXPORT JAVA_HOME RESIN_HOME
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 >
< 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 >
...
< 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 >
ResinConfigServer localhost 6802
< Location / caucho-status >
SetHandler caucho-status
</ Location >
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 >
< 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 >
修改 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 >
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 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 >
< 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 >
<
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 >
< 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 >
bin/httpd.sh -pid domainname1.pid -conf conf/domainname1.conf start
bin/httpd.sh -pid domainname2.pid -conf conf/domainname2.conf start
bin/httpd.sh -pid domainname2.pid -conf conf/domainname2.conf start