简体   繁体   English

带有Tomcat 7的Cpanel服务器中Java War文件部署的问题

[英]Issues with java war file deployment in Cpanel server with Tomcat 7

Issues with Tomcat deployment in a Cpanel/WHM server. Cpanel / WHM服务器中的Tomcat部署问题。

I was trying to deploy multiple java war files in a Cpanel server but was stuck with many things. 我试图在Cpanel服务器中部署多个Java war文件,但遇到很多麻烦。 I have searched many articles and tried implementing that but none worked. 我搜索了许多文章,并尝试实施该文章,但均无济于事。 Please see below. 请看下面。

  1. Which is the exact location that you want to deploy the java war file. 您要部署Java war文件的确切位置。 Is it the /home/user/public_html or /usr/local/easy/share/easy-tomcat7/webapps . /home/user/public_html还是/usr/local/easy/share/easy-tomcat7/webapps

  2. For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps directory. 对我来说,我已经将war文件部署在/usr/local/easy/share/easy-tomcat7/webapps目录中。 We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. 我们将war文件放置在此位置,并从WHM重新启动了tomcat,该文件被自动部署。 Is this how we should do? 这是我们应该怎么做?

  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. 我能够部署一个war文件,并且在server.xml文件中将端口从8080更改为80,并且工作正常。 But when I tried to deploy multiple war files it is causing issues. 但是,当我尝试部署多个war文件时,这会引起问题。 Please let me know we need to deploy multiple war files in a Cpanel server? 请让我知道我们需要在Cpanel服务器中部署多个war文件吗?

  4. 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. 同样,一旦部署了war文件,我们就只需在目录内的文件中进行少量代码更改即可将路径从本地路径更改为服务器路径。 But the war file gets deployed each time when the tomcat gets restarted. 但是,每次重新启动tomcat时,都会部署war文件。

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. war文件先前是在tomcat 5.5版本中部署的,现在我们正在尝试在tomcat 7中部署它。我们已经停止了服务器上的httpd服务,并且tomcat监听了端口80。 Also in the catalina.out file no particular errors are shown as it is mentioned that every thing loaded. 同样在catalina.out文件中没有显示任何特定错误,因为提到了每件事都已加载。 Please let me know how we need to deal with the above steps so that i proceed to the next. 请让我知道我们需要如何处理上述步骤,以便我继续进行下一个步骤。 Thanks in Advance. 提前致谢。

Which is the exact location that you want to deploy the java war file. 您要部署Java war文件的确切位置。 Is it the /home/user/public_html or /usr/local/easy/share/easy-tomcat7/webapps. 是/ home / user / public_html还是/ usr / local / easy / share / easy-tomcat7 / webapps。

Answer : The correct location is /usr/local/easy/share/easy-tomcat7/webapps. 答:正确的位置是/ usr / local / easy / share / easy-tomcat7 / webapps。 The other location is for " Apache HTTP Server" which supports php html etc. 另一个位置用于“ Apache HTTP Server”,它支持php html等。

2.For me i have deployed the war file in /usr/local/easy/share/easy-tomcat7/webapps directory. 2.对我来说,我已经将war文件部署在/ usr / local / easy / share / easy-tomcat7 / webapps目录中。 We have placed the war file in this location and restarted tomcat from WHM and the file got deployed automatically. 我们将war文件放置在此位置,并从WHM重新启动了tomcat,该文件被自动部署。 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. 在server.xml中的Host元素上设置autoDeploy =“ true”。 From my experience, i prefer restarting tomcat after deployment . 根据我的经验,我更喜欢在部署后重新启动tomcat。

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. 3.我能够部署一个war文件,并且在server.xml文件中将端口从8080更改为80,并且工作正常。 But when I tried to deploy multiple war files it is causing issues. 但是,当我尝试部署多个war文件时,这会引起问题。 Please let me know we need to deploy multiple war files in a Cpanel server? 请让我知道我们需要在Cpanel服务器中部署多个war文件吗?

Ans The apache HTTP webserver uses port 80 by default. Ans默认情况下,Apache HTTP Web服务器使用端口80。 so if you change the tomcat port to 80 then make sure you change apache HTTP server port to something else. 因此,如果将tomcat端口更改为80,请确保将apache HTTP服务器端口更改为其他端口。 Also changing port of Apache tomcat is a bad for security. 另外,更改Apache tomcat的端口也不利于安全。 check on google why. 检查谷歌为什么。 The normal practise is to run apache HTTP server as proxy and forward jsp request from apache to Tomcat. 通常的做法是将apache HTTP服务器作为代理运行,并将jsp请求从apap转发到Tomcat。 This requires some server administration skills. 这需要一些服务器管理技能。

  1. 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. 同样,一旦部署了war文件,我们就只需在目录内的文件中进行少量代码更改即可将路径从本地路径更改为服务器路径。 But the war file gets deployed each time when the tomcat gets restarted. 但是,每次重新启动tomcat时,都会部署war文件。

Not really clear what you meant. 不太清楚你的意思。 But if auto deployment is on some changes are automatically updated. 但是,如果启用了自动部署,则某些更改会自动更新。 I would usually down tomcat. 我通常会掉下tomcat。 delete the previous war file and removed the extracted folder and then redeploy the new changed war file. 删除先前的war文件并删除提取的文件夹,然后重新部署新的更改的war文件。 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 . 无需停止http服务。 just change port of http service to other than 80. and tomcat will work on port 80. 只需将http服务的端口更改为80以外的其他端口即可,tomcat将在端口80上运行。

My suggestion for you is to follow these steps 我对您的建议是遵循以下步骤

  1. First make sure your app is working fine in localhost or local machine. 首先,请确保您的应用在localhost或本地计算机上运行正常。

  2. If it is working in localhost and any error in server. 如果它在localhost中运行并且服务器中有任何错误。 check version of tomcat on both machines and see if that is what you are aiming for. 在两台机器上检查tomcat的版本,看看这是否是您想要的。

  3. Make sure tomcat is working on the server. 确保tomcat在服务器上正常工作。 Check if it is listening on port 8080(default).Then upload you example.war file to webapps folder. 检查它是否正在监听8080端口(默认),然后将example.war文件上传到webapps文件夹。 Restart tomcat. 重新启动tomcat。

  4. Wait for two minutes.Check if your example.war is working from link www.yourdomainname.com:8080/example . 等待两分钟,通过www.yourdomainname.com:8080/example链接检查example.war是否正常工作。

  5. 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) . (此步骤被认为是安全性不佳的做法。仅在测试步骤中提及)。如果可行,则可以尝试将apache http服务器的端口从80更改为其他端口(确保未使用端口)。 then change port of tomcat to 80. Then rename your example example.war to ROOT.war inside webapp . 然后将tomcat的端口更改为80。然后在webapp中将示例example.war重命名为ROOT.war。 delete previous exiting ROOT directory. 删除先前退出的ROOT目录。 restart apache http server then tomcat. 重新启动apache http服务器,然后重新启动Tomcat。 see if tomcat is listening in port 80 then try if your app is working from www.yourdomainname.com. 查看tomcat是否正在监听端口80,然后尝试从www.yourdomainname.com运行您的应用。 If yes then it is good. 如果是,那就很好。

  6. Now we need to retrace previous step as running tomcat on port 80 is considered bad for security. 现在我们需要回溯上一步,因为在端口80上运行tomcat被认为对安全性不利。 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. 正确的常规做法是将Apache HTTp服务器放在端口80上:将apache http服务器配置为将.jsp请求重定向到端口8080上的apache tomcat。设置为tomcat端口8080。但这需要一些系统管理员专业知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM