Apache整合resin通过虚拟主机架设多个java项目

http://www.linuxfans.org/bbs/vie ... &extra=page%3D1
以上是该问题的老帖有详细的鄙人配置说明

Apache配置方案:
在刚刚安装好的最原始的配置好resin的httpd.conf中添加或更改如下:

在这个地方
#ServerName www.example.com:80 加入ServerName,目的是为了局域网内启动服务
ServerName www.顶级域名壹.com     无所谓,这里起什么名都行

找到这个地方添加一个 空格 index.jsp
<IfModule dir_module>
    DirectoryIndex index.html index.jsp
</IfModule>

如果成功整合了resin,  httpd.conf中就会有这样的话:
#
# mod_caucho Resin Configuration
#
LoadModule caucho_module /usr/local/apache2/modules/mod_caucho.so
ResinConfigServer 127.0.0.1 6802
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
我将 ResinConfigServer 127.0.0.1 6802 这里的IP与resin.conf中如下对应
<cluster>
      <srun server-id="" host="127.0.0.1" port="6802"/>
</cluster>

继续我在末尾添加如下为的是查看caucho-status
<Location /caucho-status>
  SetHandler caucho-status
</Location>

然后我开始在httpd.conf中配置我的Apache 虚拟主机
鄙人在/etc/sysconfig/network-scripts目录中 复制了两个新的ifcfg-eth0文件
这样目录下就有三个文件如下:

文件ifcfg-eth0内容:
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:15:17:11:31:F4

#hero <start>
IPADDR=192.168.1.102
GATEWAY=192.168.1.1
#hero <end>

ONBOOT=yes
TYPE=Ethernet

#hero <start>
IPV6INIT=yes
PEERDNS=yes
#hero <end>

文件ifcfg-eth0:0内容:
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper)
DEVICE=eth0:0
# BOOTPROTO=dhcp
BOOTPROTO=static
HWADDR=00:15:17:11:31:F4

#hero <start>
IPADDR=192.168.1.106
GATEWAY=192.168.1.1
#hero <end>

ONBOOT=yes
TYPE=Ethernet

#hero <start>
IPV6INIT=yes
PEERDNS=yes
#hero <end>

添加第一个虚拟主机:这里的192.168.1.100在前面的贴子中鄙人已经讲过是我/etc/sysconfig/network-scripts/ifcfg-eth0文件我的网卡 内部IP地址为192.168.1.100
<VirtualHost 192.168.1.100:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/项目壹/WebRoot
    ServerName 192.168.1.100
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
    <Directory "/var/www/html/项目壹/WebRoot">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
</VirtualHost>

添加第二个虚拟主机对应的是/etc/sysconfig/network-scripts/ifcfg-eth0:0文件我的虚拟假网卡内部IP地址为192.168.1.106
<VirtualHost www.顶级域名贰.com>

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/项目贰/WebRoot
    ServerName www.顶级域名贰.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common

    <Directory "/var/www/html/项目贰/WebRoot">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
</VirtualHost>
以上是虚拟主机apache配置文件httpd.conf中默尾添加的
同样在resin.conf中要有与其相对应,我只改了resin.conf三处地方

第一处找到<http>:
<!-- The http port -->
    <http server-id="" host="192.168.1.100" port="8080"/>
    <http server-id="" host="192.168.1.106" port="8080"/>

第二处找到<srun>:
<cluster>
      <srun server-id="" host="127.0.0.1" port="6802"/>
</cluster>

第三处我找到<host>删除默认的添加了两个host为的是与apache相对应
<host id="www.顶级域名壹.com" root-directory=".">
      <web-app id="/" document-directory="/var/www/html/项目壹/WebRoot"/>
      <resin:if test="${java.isJava5()}">
        <resin:set var="resin_admin_password"  default=""/>
        <resin:set var="resin_admin_localhost" default="true"/>
        <web-app id="/resin-admin" document-directory="${resin.home}/php/admin"/>
       </resin:if>
    </host>

    <host id="www.顶级域名贰.com" root-directory=".">
      <web-app id="/" document-directory="/var/www/html/项目贰/WebRoot"/>
      <resin:if test="${java.isJava5()}">
        <resin:set var="resin_admin_password"  default=""/>
        <resin:set var="resin_admin_localhost" default="true"/>
        <web-app id="/resin-admin" document-directory="${resin.home}/php/admin"/>
       </resin:if>
    </host>

以上是在下与同学千锤百炼得到的成功一半的例子
就是在网上敲入www.顶级域名壹.com项目起动的是192.168.1.100resin起动的项目
同上同理再敲入www.顶级域名贰.com项目起动的是192.168.1.106resin起动的项目
但是第二个项目虽然功能较正常但是没有css 没有了图片也就是凡是涉及到路径的地方都没有但是servlet正常转方没问题。显示数据库内容没问题,后来发现项目路径有问题将两个项目对掉。问题也是一样,只不过是顶级域名贰的项目正常,壹的项目就没css了,也就正明了项目没问题,一定是httpd.conf或resin.conf的错,若众师需要改动哪里进行测试,我可以代劳把测试结果发布到这里供大家研究。