现在做了一个站点,本地测试时,通过http://localhost:8080/mysite来访问,现在如何通过tomcat实现通过http://www.mysite.com的形式来访问,前提是在本地测试,服务器用的是tomcat,在局域网内可以通过http://www.mysite.com来访问,需要些什么配置,在关键点最好能够给出解释,有其实目录结构和路劲这一块,在网上搜索了很多,但是没有详细的回答,在这个高手如云的地方,希望能够得到指点。
追加一个问题就是,如果要实现二级域名的自动管理,实现用户申请一个二级域名,得到审核以后马上就可以访问,这个又该如何实现,如主站的域名为http://www.mysite.com,二级域名为http://user.mysite.com。

解决方案 »

  1.   

    没有DNS服务器,只是本地测试
      

  2.   

    在本机的host文件中 配置www.mysite.com  localhost在tomcat中将端口改为80端口,并将tomcat默认指定的项目为mysite项目,这2步操作都在service.xml下。
      

  3.   

    前几天开发完一个供应商的录货系统。
    就把它放到外网了。
    其实很简单。只要在路由器上做一下NAT转换就行了。
    把内网的ip和端口映射到外网就行了。
      

  4.   


    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/你得工程
      

  5.   

    我现在是 在本地测试,没有dns服务器,也没进行nat转换。
      

  6.   

    《Context path="" docBase="d:\Apache Software Foundation\Tomcat 5.0\webapps\firstloong\web" debug="0"/》 是虚拟目录的配置,可以不用
      

  7.   

    没有dns服务器没关系,能连外网嘛,如可以,找个花生壳,就可以啦
      

  8.   

    server.xml中做了如下的修改:<Connector port="80" protocol="HTTP/1.1" 
                   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是提示对不起,不存在与当前域名相匹配的站点
    请检查您的访问域名是否正确。
    如果想让您的网站支持多个域名访问,请到后台设置域名别名

      

  9.   

    8楼的方法是对的,访问方式http://www.jeecms.com:8080/xxx
      

  10.   

    八楼的方法是完全正确的!你可以把
    《Context path="" docBase="d:\Apache Software Foundation\Tomcat 5.0\webapps\firstloong\web" debug="0"/》
    去掉,这是设置虚拟路径。只要你把你的项目放在webapp下就行了!
    ①修改你的sever.xml文件,按照八楼方法修改
    ②修改你的系统文件,路径如下:C:\WINDOWS\system32\drivers\etc\hosts 搞定!
      

  11.   

    对于jeecms里面进行了设置,没法直接修改,他其实采用地址转发的功能,将多个地址转发到一个域名上去。