Deploy WebApp in Tomcat8.0 and Bind a Domain
Get an available domain
- get a domain:use freenom
- DNS: use dnsla
- put the host message of dnsla into your domain manage in freenom
- try to ping it.
- Port mapping: for me,I use hiwifi as my routers,
Prepare
I use eclipse to write my J2EE webapps, but eclipse does not support remote host.
the default webapps is stored in <YOUR_WORKSPACE>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
however, the default webapps path in Tomcat is <CATALINA_BASE>\webapps(or < CATALINA_HOME >\webapps, for example:E: omcat)
Thus,we need to copy the webapp from <YOURWORKSPACE>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps into <CATALINA_BASE>/webapps
We can do it automatically in Eclipse,
- open configuration of server in eclipse
- clear the deployed apps below the server(if exists)
- start the server
- change Server location into use Tomcat location,set server path = <CATALINA_BASE>, set deploy path = webapps
- ctrl+s save it.
Before:
After:
Edit server.xml
- open <CATALINA_BASE>\conf\server.xml.
-
replace
<Engine defaultHost="localhost" name="Catalina">
as
<Engine defaultHost="<YOUR_DOMAIN>" name="Catalina">
or
<Engine defaultHost="<YOUR_IP>" name="Catalina">
-
replace
as
<Host appBase="webapps" autoDeploy="true" name="<YOUR_DOMAIN>" unpackWARs="true">
or
<Host appBase="webapps" autoDeploy="true" name="<YOUR_IP>" unpackWARs="true">
- start <CATALINA_BASE>in\startup.bat.
-
Attention
- eclipse will automically change the server configuration in Tomcat, so need to correct server.xml each time we use eclipse in this workspace.
- China Telecom ban the direct access of port 80,8080 unless we have put the official records, so I use port 8110.
- use startup.bat other than directly use tomcat8.exe