tomcat的版本是6.0
下面是我的tomcat的server.xml文件<?xml version='1.0' encoding='utf-8'?><Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources> <Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host> </Engine>
</Service>
</Server>
我想增加一个虚拟主机,如“testhost”,应该只要增加这么一个节点就可以了吧:<Host name="testhost" appBase="testwebapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
但是不行,访问 http://testhost:8080/ 提示找不到服务器。"testwebapps"这个文件夹存在并且拥有与"webapps"一样的目录结构。
好吧,那我就做实验,让server.xml里就存在一个host:<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>把 name="localhost" 改为:name="myhost",但是访问 http://myhost:8080/ 仍然找不到服务器。
为什么?tomcat增加虚拟主机有这么麻烦?
下面是我的tomcat的server.xml文件<?xml version='1.0' encoding='utf-8'?><Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources> <Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host> </Engine>
</Service>
</Server>
我想增加一个虚拟主机,如“testhost”,应该只要增加这么一个节点就可以了吧:<Host name="testhost" appBase="testwebapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
但是不行,访问 http://testhost:8080/ 提示找不到服务器。"testwebapps"这个文件夹存在并且拥有与"webapps"一样的目录结构。
好吧,那我就做实验,让server.xml里就存在一个host:<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>把 name="localhost" 改为:name="myhost",但是访问 http://myhost:8080/ 仍然找不到服务器。
为什么?tomcat增加虚拟主机有这么麻烦?
127.0.0.1好像在TOMCAT改不成..要改WINDOWS文件..
就行了
谢谢1楼