Tomcat虚拟主机的配置

来源:互联网 发布:最强网络神豪笔趣阁 编辑:程序博客网 时间:2024/05/19 13:22

具体步骤:

1、在conf的server.xml文件配置虚拟主机名和对应物理路径

name=”www.it.gdut”:虚拟主机名
appBase=”E:\myhome”:物理路径

在conf\Catalina文件夹下面就会生成www.it.gdut文件夹

2、在电脑system32drivers文件夹下的etc文件下的host文件配置虚拟机名对应的静态ip地址:
127.0.0.1 www.it.gdut
3、可以设置默认的虚拟主机名,即在

defaultHost=”localhost”:默认虚拟主机名

下面看看完整配置:

<Engine name="Catalina" defaultHost="localhost">      <!--For clustering, please take a look at documentation at:          /docs/cluster-howto.html  (simple how to)          /docs/config/cluster.html (reference documentation) -->      <!--      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>      -->      <!-- Use the LockOutRealm to prevent attempts to guess user passwords           via a brute-force attack -->      <Realm className="org.apache.catalina.realm.LockOutRealm">        <!-- This Realm uses the UserDatabase configured in the global JNDI             resources under the key "UserDatabase".  Any edits             that are performed against this UserDatabase are immediately             available for use by the Realm.  -->        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"               resourceName="UserDatabase"/>      </Realm>      <Host name="localhost"  appBase="webapps"            unpackWARs="true" autoDeploy="true">        <!-- SingleSignOn valve, share authentication between web applications             Documentation at: /docs/config/valve.html -->        <!--        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />        -->        <!-- Access log processes all example.             Documentation at: /docs/config/valve.html             Note: The pattern used is equivalent to using pattern="common" -->        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="localhost_access_log" suffix=".txt"               pattern="%h %l %u %t &quot;%r&quot; %s %b" />      </Host>      <Host name="www.it.gdut"  appBase="E:\myhome"/>    </Engine>
0 0