如何将域名部署到Tomcat中,用域名访问服务器

前提:我的域名是www.xxxx.top

1.打开Tomcat所在文件夹,找到conf文件夹下的server.xml文件,打开编辑它

2.将下面的8080端口改为80端口

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

3.将下面的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) -->

4.第一行的name=”localhost”中的localhost改为你的域名在最后Host关闭标签前加上<Context docBase="com.weiXin" path="" reloadable="true" ></Context>这句话中的docBase里面放你发布的项目的名字

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="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" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>

      <Context docBase="D:apache-tomcat-8.0.46webappscom.weiXin" path="/com.weiXin" reloadable="true" source="org.eclipse.jst.jee.server:com.weiXin"/><Context docBase="D:apache-tomcat-8.0.46webappscom.CDSN" path="/com.CDSN" reloadable="true" source="org.eclipse.jst.jee.server:com.CDSN"/></Host>
经验分享 程序员 微信小程序 职场和发展