Tomcat removes port number and project name

   At the end of a project, it is often directly mapped to an IP address as needed. At this point, you need to remove the port and project name, when accessing. An implementation method is provided below according to a specific example.   
  1. After entering TOMCAT_HOME, create a folder and name it webdb (here is webdb, which can be changed to other names as needed.). 
  2. Enter the webdb folder, and create a ROOT (where ROOT is capitalized) folder in it, copy all the contents of your project back to ROOT. Then go to TOMCAT_HOME\webapps, copy the balancer folder to the webdb folder. 
   3. In TOMCAT_HOME\conf\server.xml, find this sentence:
<host name="localhost" appbase="webapps"></host>
unpackWARs="true" autoDeploy="true" xmlValidation="false xmlNamespaceAware ="false"> Then replace webapps in appBase="webapps" with webdb.
<host name="localhost" appbase="webdb"></host> 
unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> 

5. Remove the port number without going into details. Just open TOMCAT_HOME\conf\server.xml to find the original port number (such as 8080), and after modifying it to 80, you can access without entering the port number. But be careful to prevent other programs from occupying port 80. 
6. Some friends may say, why not delete the content in ROOT in webapps, and then copy the project back to ROOT, in this case, the desired effect can also be achieved. On this point I think so, in fact, there are many ways. All roads lead to Rome. Another advantage of doing this is that when using the TOMCAT console, you can easily modify the directory back.  
  Tomcat virtual host configuration scheme (domain name resolution) For Windows/Linux (the most complete version
) 1. Open the conf/server.xml file in the tomcat installation directory and find it in the server.xml document </Engine> </Service> Then add the above Add the following content (for the time being, there are three ways):
The first one: <Host name="
www.5sai.net.cn" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="www" debug="0" reloadable="true" crossContext="true"/> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="www_5sai_log." suffix=".txt" timestamp ="true"/> </Host>  
The above content is to create a new www folder in Tomcat's webapps directory as
the main directory of the domain name www.5sai.net.cn
The second: <Host name="test.5sai.net.cn" debug="0" appBase="C:\\test\www" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="."/> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="test_5sai_access_log." suffix=".txt" pattern="common" resolveHosts="false"/ > <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="test_5sai_log." suffix=".txt" timestamp="true"/> </Host> The above content means that Create a www folder under the test folder of the C drive as the main directory of the domain name test.5sai.net.cn

  The third type, if /var/www of the Linux system is used as the main directory of the domain name test.5sai.net.cn, the content is as follows: <Host name="test.5sai.net.cn" debug="0" appBase= "/var/www" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="."/> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="test_5sai_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="test_5sai_log." suffix=".txt" timestamp="true"/> </Host> 
add another <Host name="
www.5sai.net.cn"  debug="0"  unpackWARs="true">           <Valve  className="org.apache.catalina.valves.AccessLogValve"                                     directory="/var/log/tomcat"    prefix="www_5sai_access_log."  suffix=".txt"                                     pattern="common"/>                   <Logger  className="org.apache.catalina.logger.FileLogger"                                    directory="/var/log/tomcat"    prefix="www_5sai_log."  suffix=".txt"                               timestamp="true"/>                                                     <Context  path=""  docBase="/var/www"  debug="0"  reloadable="true"/>               </Host>The main directory of the     for testing: www.5sai.net.cn is /var/www. All access logs of this site are placed in /ar/log/tomcat
domain name


Windows users open the hosts file of C:\WINDOWS\system32\drivers\etc, linux users open the hosts file of /ect or vi /ect/hosts and modify the content as follows 
127.0.0.1 localhost 127.0.0.1      
www.5sai.net.cn 127.0 .0.1 test.5sai.net.cn Then open the browser and directly enter the URL to test!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326996474&siteId=291194637