现在做了一个站点,本地测试时,通过http://localhost:8080/mysite来访问,现在如何通过tomcat实现通过http://www.mysite.com的形式来访问,前提是在本地测试,服务器用的是tomcat,在局域网内可以通过http://www.mysite.com来访问,需要些什么配置,在关键点最好能够给出解释,有其实目录结构和路劲这一块,在网上搜索了很多,但是没有详细的回答,在这个高手如云的地方,希望能够得到指点。
追加一个问题就是,如果要实现二级域名的自动管理,实现用户申请一个二级域名,得到审核以后马上就可以访问,这个又该如何实现,如主站的域名为http://www.mysite.com,二级域名为http://user.mysite.com。
追加一个问题就是,如果要实现二级域名的自动管理,实现用户申请一个二级域名,得到审核以后马上就可以访问,这个又该如何实现,如主站的域名为http://www.mysite.com,二级域名为http://user.mysite.com。
就把它放到外网了。
其实很简单。只要在路由器上做一下NAT转换就行了。
把内网的ip和端口映射到外网就行了。
server.xml中《Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /》
改为 《Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /》 《Engine name="Catalina" defaultHost="warison2008.gicp.net"》修改《Host》标签,改成 《Host name="***.voip.net" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"》
《Context path="" docBase="d:\Apache Software Foundation\Tomcat 5.0\webapps\firstloong\web" debug="0"/》
《/Host》
重新启动tomcat就可以了
在修改下
C:\WINDOWS\system32\drivers\etc\hosts 127.0.0.1 warison2008.gicp.net
端口处修改,可选,若不改就使用http://warison2008.gicp.net:8080/你得工程,应该http默认的端口是80,所以改为80端口可以直接使用http://warison2008.gicp.net/你得工程
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
以及:
<Engine name="Catalina" defaultHost="localhost"><!-- the content below is inserted manmuel at 2010-01-10-->
<Host name="www.jeecms.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!--我的源文件是放在C:\Tomcat 6.0\webapps\www.jeecms.com中的-->
<Context path="" docBase="C:\Tomcat 6.0\webapps\www.jeecms.com" debug="0"></Context>
</Host>在hosts中我的如下# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host127.0.0.1 www.jeecms.com在浏览器中输入http://www.jeecms.com是提示对不起,不存在与当前域名相匹配的站点
请检查您的访问域名是否正确。
如果想让您的网站支持多个域名访问,请到后台设置域名别名
《Context path="" docBase="d:\Apache Software Foundation\Tomcat 5.0\webapps\firstloong\web" debug="0"/》
去掉,这是设置虚拟路径。只要你把你的项目放在webapp下就行了!
①修改你的sever.xml文件,按照八楼方法修改
②修改你的系统文件,路径如下:C:\WINDOWS\system32\drivers\etc\hosts 搞定!