Reputation: 451
Issues with Tomcat deployment in a Cpanel/WHM server.
I was trying to deploy multiple java war files in a Cpanel server but was stuck with many things. I have searched many articles and tried implementing that but none worked. Please see below.
Which is the exact location that you want to deploy the java war file. Is it the /home/user/public_html
or /usr/local/easy/share/easy-tomcat7/webapps
.
For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps
directory. We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. Is this how we should do?
I was able to deploy a single war file and I have made the port change from 8080 to 80 in the server.xml
file and it was working fine. But when I tried to deploy multiple war files it is causing issues. Please let me know we need to deploy multiple war files in a Cpanel server?
Also Once the war file got deployed then we have made few code changes in the files inside the directory to change the path from local path to server path. But the war file gets deployed each time when the tomcat gets restarted.
The war file was earlier deployed in tomcat 5.5 version and now we are trying to deploy this in tomcat 7. We have stopped the httpd service on the server and the port 80 is listened by tomcat. Also in the catalina.out file no particular errors are shown as it is mentioned that every thing loaded. Please let me know how we need to deal with the above steps so that i proceed to the next. Thanks in Advance.
Upvotes: 1
Views: 2584
Reputation: 1965
Which is the exact location that you want to deploy the java war file. Is it the /home/user/public_html or /usr/local/easy/share/easy-tomcat7/webapps.
Answer : The correct location is /usr/local/easy/share/easy-tomcat7/webapps. The other location is for " Apache HTTP Server" which supports php html etc.
2.For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps directory. We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. Is this how we should do?
You could always hot deploy . Meaning no need to restart. Set autoDeploy="true" on the Host element in server.xml. From my experience, i prefer restarting tomcat after deployment .
3.I was able to deploy a single war file and I have made the port change from 8080 to 80 in the server.xml file and it was working fine. But when I tried to deploy multiple war files it is causing issues. Please let me know we need to deploy multiple war files in a Cpanel server?
Ans The apache HTTP webserver uses port 80 by default. so if you change the tomcat port to 80 then make sure you change apache HTTP server port to something else. Also changing port of Apache tomcat is a bad for security. check on google why. The normal practise is to run apache HTTP server as proxy and forward jsp request from apache to Tomcat. This requires some server administration skills.
Not really clear what you meant. But if auto deployment is on some changes are automatically updated. I would usually down tomcat. delete the previous war file and removed the extracted folder and then redeploy the new changed war file. Works for me as in the env i work few minutes of downtime is ok. Change your steps according to your requirement. No need to stop http service . just change port of http service to other than 80. and tomcat will work on port 80.
My suggestion for you is to follow these steps
First make sure your app is working fine in localhost or local machine.
If it is working in localhost and any error in server. check version of tomcat on both machines and see if that is what you are aiming for.
Make sure tomcat is working on the server. Check if it is listening on port 8080(default).Then upload you example.war file to webapps folder. Restart tomcat.
Wait for two minutes.Check if your example.war is working from link www.yourdomainname.com:8080/example .
If it is not working , debug errors and resolve it. (This step is considered bad practice for security. just mentioning it as a testing step )If working then you could try changing port of apache http server from 80 to somethings else(make sure port unused) . then change port of tomcat to 80. Then rename your example example.war to ROOT.war inside webapp . delete previous exiting ROOT directory. restart apache http server then tomcat. see if tomcat is listening in port 80 then try if your app is working from www.yourdomainname.com. If yes then it is good.
Now we need to retrace previous step as running tomcat on port 80 is considered bad for security. if it is ok in the environment you deploy then you could use this setup. Correct normal practise is put Apache HTTp server on port 80: configure apache http server to redirect .jsp request to apache tomcat on port 8080. make tomcat port 8080. But this requires some system admin expertise.
Upvotes: 2