简体   繁体   English

通过Apache Tomcat 6.0进行VirtualHosting

[英]VirtualHosting through Apache Tomcat 6.0

I am having the domain(any three) and want that it should run with the same port that the tomcat is having(8080). 我正在使用域(任何三个域),并希望它与tomcat具有的端口相同(8080)。 I have done upto that the adding the domain name and appbase in SERVER.XML . 我已经完成了在SERVER.XML中添加域名和appbase的工作

    <Host name="www.hello.com"  appBase="hello_webapps"
        unpackWARs="true" autoDeploy="true"/>

<Host name="www.hi.com"  appBase="hi_webapps"
       unpackWARs="true" autoDeploy="true"/>

<Host name="www.bye.com"  appBase="bye_webapps"
        unpackWARs="true" autoDeploy="true"/>

and change in the host file of etc 并更改等的主机文件

 xxx.xxx.x.xx www.hello.com
 xxx.xxx.x.xx www.hi.com
 xxx.xxx.x.xx www.bye.com

XXX.XXX.X.XX is the ip address but by running www.hello.com:8080,it is giving the error 404. XXX.XXX.X.XX是IP地址,但是通过运行www.hello.com:8080,它给出了错误404。

There are tree essentials part TODO to establish virtual hosting in tomcat : 在tomcat中建立虚拟主机有TODO的树要件:

  • DNS configuration DNS配置

You have to prepare your domain names and IP and configure your DNS server,the alternative is to use hosts file for test/dev . 您必须准备域名和IP并配置DNS服务器,替代方法是使用hosts文件进行test / dev。

  • Server.xml configuration Server.xml配置

this step is to map deployed apps folder with the domain names that will be used when requesting the Tomcat server 此步骤是使用请求Tomcat服务器时将使用的域名映射已部署的apps文件夹

example from official doc : 来自官方文档的示例:

<Engine name="Catalina" defaultHost="ren">
    <Host name="ren"    appBase="renapps"/>
    <Host name="stimpy" appBase="stimpyapps"/>
</Engine>
  • Deploiement appliction folder 部署应用文件夹

put the content of your app inside a folder called ROOT which will be inside the folder used in server.xml configuration (renapps in the example, the content will be in renapps/ROOT/ ) 将您的应用程序内容放入名为ROOT的文件夹中,该文件夹将位于server.xml配置中使用的文件夹中(示例中为renapps,内容将位于renapps/ROOT/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM