tomcat多域名配置
2013-04-18 14:35
11 查看
http://blog.csdn.net/chenhui1219/article/details/6046925
网?这一系列的问题,今天就这个问题,我来说一下。
域名如何跟项目绑定到一起呢?server.xml。修改<Host name="我们所要绑定的域名" ##默认情况下为localhost
debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>注意:如果tomcat只部署一个应用,但是有多个域名的情况下,就无需绑定域名,只需用默认的localhost即可,无论你输入啥域名,只要nginx给你转发过来,就能访问到我们的应用。如果你不用nginx,直接用tomcat发布,那就看解析什么域名到服务器上了
4. 当启动tomcat的时候,输入我们绑定的域名,是不是看到了我们的tomcat。可是我们想访问我们的项目还得再域名后面加上项目名称才能访问到,也
就是说到现在我们的域名还没跟项目绑定到一起。我们在看一下第三部,想让我们的项目和域名绑定到一起,我们只需要在</Host>前面加上<Context
docBase="项目名" path="" reloadable="true" >即可。
例如:<Host name="www.abc.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false"><Context docBase="baidu" path="" reloadable="true" ></Host>
5. 当我们的有两个项目都放在同一个tomcat下的时候,我们只需要把<Host></ Host>加上两个既可以完成我们的2个项目的绑定,但是项目名称别忘了改哦。----------------------------------------------------------------
域名绑定与虚拟目录设置:
server.xml 的修改方式如下:
(一)多域名绑定
1.如果你要绑定网站,首先是要把tomcat的默认访问端口8080,修改成80
原始:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改后:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
其实这里就是把port:8080,修改成port:80就可以了,其他的参数不变
2.接下来就是重点了哈哈...
单个域名绑定:
原始:
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" />
</Engine>
当然这里我把注释代码统统删除掉了,省的碍眼
修改后:
<Host name="www.aaa.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
<Host name="www2.aaa.com" debug="0" appBase="d:/wwwroot/chengqun1"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun1"></Context>
</Host>
多域名绑定:
<Host name="chengqun.202.71one.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>chengqun.aaa.com</Alias>
<Alias>chengqun1.aaa.com</Alias>
<Alias>chengqun2.aaa.com</Alias>
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
(二)虚拟目录
(1)
<Host name="chengqun.aaa.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/chengqun" docBase="d:/wwwroot/chengqun"></Context>
</Host>
其中,Host标记是用来配置虚拟主机的,就是可以多个域名指向一个tomcat,格式只要参考默认的就
可以了。
<context>是Host标记的子元素吧,表示一个虚拟目录,它主要有两个属性,path就相当于虚拟目录名字,
而 docbase则是具体的文件位置。在这里我的虚拟路径名称为chengqun,实际上我的程序也就是html、jsp、servlet都 放在了d:/wwwroot/chengqun这
个目录下了。
这样我就可以通过 chengqun.aaa. com/chengqun 访问我的这个虚拟目录了。
另外一种方法是:
<Host name="chengqun.aaa. com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
这样设置以后,输入域名可以访问这个站点程序了(Context path="/"这里不同)
(2)
没有指定默认站点,所以直接输入IP的时候,无法访问。如何让输入ip就可以访问指定的站点呢?
修改server.xml的 <Engine name="Catalina" defaultHost="chengqun.202. com">
这样就可以实现了输入ip访问chengqun.aaa. com这个站点的程序了!
----------------------------------------
tomcat下的配置都在conf下的server.xml下实现。。。
里面从高到低分为:
Server
--Service
--Connector
--Engine
--Host
--Context
网?这一系列的问题,今天就这个问题,我来说一下。
域名如何跟项目绑定到一起呢?server.xml。修改<Host name="我们所要绑定的域名" ##默认情况下为localhost
debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>注意:如果tomcat只部署一个应用,但是有多个域名的情况下,就无需绑定域名,只需用默认的localhost即可,无论你输入啥域名,只要nginx给你转发过来,就能访问到我们的应用。如果你不用nginx,直接用tomcat发布,那就看解析什么域名到服务器上了
4. 当启动tomcat的时候,输入我们绑定的域名,是不是看到了我们的tomcat。可是我们想访问我们的项目还得再域名后面加上项目名称才能访问到,也
就是说到现在我们的域名还没跟项目绑定到一起。我们在看一下第三部,想让我们的项目和域名绑定到一起,我们只需要在</Host>前面加上<Context
docBase="项目名" path="" reloadable="true" >即可。
例如:<Host name="www.abc.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false"><Context docBase="baidu" path="" reloadable="true" ></Host>
5. 当我们的有两个项目都放在同一个tomcat下的时候,我们只需要把<Host></ Host>加上两个既可以完成我们的2个项目的绑定,但是项目名称别忘了改哦。----------------------------------------------------------------
域名绑定与虚拟目录设置:
server.xml 的修改方式如下:
(一)多域名绑定
1.如果你要绑定网站,首先是要把tomcat的默认访问端口8080,修改成80
原始:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改后:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
其实这里就是把port:8080,修改成port:80就可以了,其他的参数不变
2.接下来就是重点了哈哈...
单个域名绑定:
原始:
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" />
</Engine>
当然这里我把注释代码统统删除掉了,省的碍眼
修改后:
<Host name="www.aaa.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
<Host name="www2.aaa.com" debug="0" appBase="d:/wwwroot/chengqun1"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun1"></Context>
</Host>
多域名绑定:
<Host name="chengqun.202.71one.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>chengqun.aaa.com</Alias>
<Alias>chengqun1.aaa.com</Alias>
<Alias>chengqun2.aaa.com</Alias>
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
(二)虚拟目录
(1)
<Host name="chengqun.aaa.com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/chengqun" docBase="d:/wwwroot/chengqun"></Context>
</Host>
其中,Host标记是用来配置虚拟主机的,就是可以多个域名指向一个tomcat,格式只要参考默认的就
可以了。
<context>是Host标记的子元素吧,表示一个虚拟目录,它主要有两个属性,path就相当于虚拟目录名字,
而 docbase则是具体的文件位置。在这里我的虚拟路径名称为chengqun,实际上我的程序也就是html、jsp、servlet都 放在了d:/wwwroot/chengqun这
个目录下了。
这样我就可以通过 chengqun.aaa. com/chengqun 访问我的这个虚拟目录了。
另外一种方法是:
<Host name="chengqun.aaa. com" debug="0" appBase="d:/wwwroot/chengqun"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="d:/wwwroot/chengqun"></Context>
</Host>
这样设置以后,输入域名可以访问这个站点程序了(Context path="/"这里不同)
(2)
没有指定默认站点,所以直接输入IP的时候,无法访问。如何让输入ip就可以访问指定的站点呢?
修改server.xml的 <Engine name="Catalina" defaultHost="chengqun.202. com">
这样就可以实现了输入ip访问chengqun.aaa. com这个站点的程序了!
----------------------------------------
tomcat下的配置都在conf下的server.xml下实现。。。
里面从高到低分为:
Server
--Service
--Connector
--Engine
--Host
--Context
相关文章推荐
- tomcat 中配置域名和项目虚拟目录
- TOMCAT的域名配置
- tomcat多域名配置
- Nginx+Tomcat实现不同项目域名映射配置(超详细)
- linux apache 配置多个域名转发不同tomcat
- nginx+tomcat绑定域名配置记录
- tomcat 配置不同二级域名间session共享 还要改源码 累。。。
- Tomcat 下配置一个ip绑定多个域名
- Tomcat配置域名/IP访问及其中遇到的问题注意事项
- tomcat多域名配置
- Apache+Tomcat 同一IP多域名多网站配置
- tomcat 多域名配置
- Tomcat绑定域名配置
- 域名配置,tomcat通过域名打不开
- tomcat下域名的配置及ROOT.xml
- Tomcat 端口、默认应用、域名配置实践
- Tomcat下配置多个javaWeb,一个IP绑定多个域名
- Tomcat多域名配置
- Tomcat配置虚拟目录、多域名、多个Http监听端口的方式
- tomcat 域名配置、中文域名、别名配置