找回密码
 注册
查看: 1330|回复: 6

请教apache+tomcat整合后虚拟主机的设置问题

[复制链接]
发表于 2005-4-19 16:56:58 | 显示全部楼层 |阅读模式
我现在apache、tomcat已经整合,jsp页面已经正常解析,我的机器需要设置多个虚拟主机,每个虚拟主机下面又有多个虚拟目录,请问我该怎么设置虚拟主机?是用apache还是tomcat?谢谢
发表于 2005-4-19 17:26:49 | 显示全部楼层
当然是用apahe设置了。至于如何设置,请查看apache的中文手册,很详细
回复

使用道具 举报

 楼主| 发表于 2005-4-20 14:51:48 | 显示全部楼层
[quote:3acbbfd140="jarson"]当然是用apahe设置了。至于如何设置,请查看apache的中文手册,很详细[/quote]
我在apache设置了一个虚拟主机,但是很奇怪,根本没有生效
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.sp.cn
    DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName test.news.cn
    DocumentRoot /tomcat/webapps/web
    ErrorLog logs/test.news.cn-error_log
    CustomLog logs/test.news.cn-access_log common
</VirtualHost>

我访问test.news.cn,但是显示页面根本不是/tomcat/webapps/web的首页,而是/var/www/html页面,test.news.cn虚拟主机根本没有生效,请问这是为什么?
回复

使用道具 举报

 楼主| 发表于 2005-4-20 16:36:35 | 显示全部楼层
我没有和tomcat整合的apache虚拟主机这样设置就很正常,所有的虚拟主机都能正常工作
回复

使用道具 举报

发表于 2005-4-20 21:05:11 | 显示全部楼层
[quote:8f03e736e1="lues"][quote:8f03e736e1="jarson"]当然是用apahe设置了。至于如何设置,请查看apache的中文手册,很详细[/quote]
我在apache设置了一个虚拟主机,但是很奇怪,根本没有生效
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.sp.cn
    DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName test.news.cn
    DocumentRoot /tomcat/webapps/web
    ErrorLog logs/test.news.cn-error_log
    CustomLog logs/test.news.cn-access_log common
</VirtualHost>

我访问test.news.cn,但是显示页面根本不是/tomcat/webapps/web的首页,而是/var/www/html页面,test.news.cn虚拟主机根本没有生效,请问这是为什么?[/quote]
logs/test.news.cn-access_log 里记录的条目看来是怎样的?
回复

使用道具 举报

 楼主| 发表于 2005-4-21 11:59:10 | 显示全部楼层
[quote:6c0accae62="dannycat"][quote:6c0accae62="lues"][quote:6c0accae62="jarson"]当然是用apahe设置了。至于如何设置,请查看apache的中文手册,很详细[/quote]
我在apache设置了一个虚拟主机,但是很奇怪,根本没有生效
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.sp.cn
    DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName test.news.cn
    DocumentRoot /tomcat/webapps/web
    ErrorLog logs/test.news.cn-error_log
    CustomLog logs/test.news.cn-access_log common
</VirtualHost>

我访问test.news.cn,但是显示页面根本不是/tomcat/webapps/web的首页,而是/var/www/html页面,test.news.cn虚拟主机根本没有生效,请问这是为什么?[/quote]
logs/test.news.cn-access_log 里记录的条目看来是怎样的?[/quote]

tail -f test.news.cn-access_log
210.75.18.36 - - [20/Apr/2005:16:28:11 +0800] "GET / HTTP/1.0" 200 109
192.168.10.103 - - [21/Apr/2005:11:53:21 +0800] "GET / HTTP/1.1" 200 109
192.168.10.103 - - [21/Apr/2005:11:53:44 +0800] "GET /1.jsp HTTP/1.1" 404 970

test.news.cn-error_log 的内容为空
回复

使用道具 举报

 楼主| 发表于 2005-4-21 18:16:34 | 显示全部楼层
我下午又调了一下,给test.news.cn在apache中加了虚拟目录,然后又在tomcat中配置了test.news.cn虚拟主机,发现test.news.cn在apache中的虚拟目录使用正常,但是DocumentRoot 路径还是没有生效,访问test.news.cn显示页面是tomcat定义的test.news.cn虚拟主机根目录

apache配置
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName test.news.cn
    DocumentRoot /tomcat/webapps/web
    Alias /ContentFile "/tomcat/webapps/PicRing/ContentFile"
    Alias /Files "/tomcat/webapps/PicRing"
    Alias /stat "/tomcat/webapps/stat"
    DirectoryIndex index.htm index.html default.htm index.php index.jsp
    <Location ~ "/*.jsp|/*/servlet/*>
    JkUriSet worker ajp13:localhost:8009
    </Location>
    ErrorLog logs/test.news.cn-error_log
    CustomLog logs/test.news.cn-access_log common
</VirtualHost>

tomcat配置
<Host name="test.news.cn" debug="0" appBase="/tomcat/webapps/"
       unpackWARs="true" autoDeploy="true">
                <Context path="" docBase="WAP2005" debug="0"
                 reloadable="true" crossContext="true">
                <Logger className="org.apache.catalina.logger.FileLogger"
                     prefix="wap_log." suffix=".txt"
                  timestamp="true"/>
                </Context>
          </Host>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-22 19:26 , Processed in 0.057912 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表