1. Modify ports

Tomcat’s default listening port is 8080. If we want to access the project directly without a port, we must listen on port 80.

Server.xml follows the code snippet

connectionTimeout=”20000″

redirectPort=”8443″ />

Modified to

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
Copy the code

Second, the configuration

The first is to change the value of defaultHost to your domain name www.qiangzigz.pw” name=”Catalina”>

The second is

Change the value of name to your domain name

www.qiangzigz.pw” unpackWARs=”true” xmlNamespaceAware=”false” xmlValidation=”false”>

Finally, specific project direction is added

TestPath “path=”” reloadable=”true”/>

This testPro is the project name in Tomcat

Save the service. XML file and restart the service. If your domain name is bound to the IP address, you can access it directly using the domain name

After restarting the server, it is true that the project can be accessed by domain name, but when removing the WWW front. “, but can not access.

Since access does not mean that there is no configuration of the domain name, then added a label, the other are unchanged, only to remove the domain name in front of the WWW. Then restart the server, which was successful in theory, but turned out to be unexpected.

I can’t access it. I can’t understand it.

Later over the wall to check information, finally solved. There is also an alias tag under the original, modified code

<Host name="www.qiangzigz.pw" appBase="webapps/qxw" unpackWARs="true" autoDeploy="true"> <Alias>qiangzigz.pw</Alias> <Context path="" docBase="C: Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ QXW "debug="0" reloadable="true" ></Context> </Host>Copy the code

Restart the server and it works.