루트 응용 프로그램을 변경하는 방법?
Tomcat 6 웹 서버의 기본 응용 프로그램을 "ROOT"(webapps 폴더 내부)와 다른 응용 프로그램으로 변경하려고합니다. 가장 좋은 방법은 무엇입니까?
세 가지 방법이 있습니다.
먼저 해당
bin
디렉토리 (sh shutdown.sh
) 에서 Tomcat을 종료하십시오 . 그런 다음 Tomcatwebapps
폴더 의 모든 내용을 삭제하십시오 (rm -fr *
). 그런 다음 WAR 파일의 이름을로 바꾸고ROOT.war
마지막으로bin
디렉토리 (sh startup.sh
) 에서 Tomcat을 시작하십시오 .전쟁 파일을
$CATALINA_BASE/webapps
원래 이름으로 두십시오 . 해제 autoDeploy 및 deployOnStartup을 에 호스트 요소에server.xml
파일. 경로 및 docBase 속성을server.xml
모두 지정하여의 모든 애플리케이션 컨텍스트를 명시 적으로 정의하십시오 . 모든 Tomcat 자동 배포 메커니즘을 비활성화했기 때문에이 작업을 수행해야합니다. Tomcat은에서 Context를 찾지 않으면 더 이상 응용 프로그램을 배포하지 않습니다 .server.xml
두 번째 방법 : 응용 프로그램을 변경하려면 Tomcat을 중지했다가 다시 시작해야합니다.
WAR 파일을 외부에 두십시오
$CATALINA_BASE/webapps
(이중 배치를 방지하려면 외부에 있어야 함). 에 이름이 지정된 컨텍스트 파일ROOT.xml
을 배치하십시오$CATALINA_BASE/conf/
. 이 컨텍스트 파일의 단일 요소에는 WAR 파일의 위치를 가리키는 docBase 속성 이 있어야 합니다. 경로 요소는 설정하지 않아야합니다 ..xml
이 경우 파일 이름에서 파생됩니다ROOT.xml
. 자세한 내용은 컨텍스트 컨테이너 설명서를 참조 하십시오.
Tomcat 6 <Context>
의 <Host>
태그에 태그를 추가 server.xml
하면 문제가 해결됩니다.
당신이 사용하는 경우 path=""
비워 당신은 같은 URL을 사용할 수 있습니다 http://localhost/first.do
.
컨텍스트 태그 세트 속성 docBase="E:\struts-ITRCbook\myStrutsbook"
및 reloadable="true"
에서 컨텍스트 태그를 종료하십시오.
다음과 같이 보일 것입니다 :
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="E:\struts-ITRCbook\myStrutsbook" reloadable="true">
</Context>
</Host>
이러한 변경 사항이있는 Tomcat 7에서는 myAPP
at /
and ROOT
at 에 액세스 할 수 있습니다 ./ROOT
<Context path="" docBase="myAPP"/>
<Context path="ROOT" docBase="ROOT"/>
<Host>
server.xml 의 섹션에 위의 추가
루트 기본 응용 프로그램은 일반적으로 Tomcat Manager입니다. 유용 할 수 있으므로 유지하는 것이 좋습니다.
그래서 내 앱을 루트로 만들고 TCmgr을 유지하는 방식은 다음과 같습니다.
ROOT의 이름을 다른 것으로 변경
mv ROOT TCmgr
그런 다음 ROOT가 응용 프로그램을 가리키는 심볼릭 링크를 만들었습니다.
ln -s <your app> ROOT
나를 위해 일했고 가장 쉬운 접근법처럼 보였습니다.
다음과 같이 약간 해킹 방식 으로이 작업을 수행 할 수 있습니다.
- 톰캣 중지
- ROOT.war를 옆으로 이동하고 rm -rf webapps / ROOT
- webapps / ROOT.war에 복사하려는 웹앱을 복사하십시오.
- Tomcat 시작
Apache Tomcat 문서에 따르면 ROOT.xml 파일을 작성하여 애플리케이션을 변경할 수 있습니다. 자세한 내용은 다음을 참조하십시오.
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
"기본 웹 응용 프로그램은 ROOT.xml이라는 파일을 사용하여 정의 할 수 있습니다."
다른 해결책은 원하는 기본 웹앱으로 리디렉션을 전송하고 해당 서블릿을 ROOT 웹앱의 모든 URL에 매핑하는 서블릿을 만드는 것입니다.
package com.example.servlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RedirectServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.sendRedirect("/myRootWebapp");
}
}
위의 클래스를에 추가하십시오
CATALINA_BASE/webapps/ROOT/WEB-INF/classes/com/example/servlet
.
그리고 다음을 추가하십시오 CATALINA_BASE/webapps/ROOT/WEB-INF/web.xml
.
<servlet>
<display-name>Redirect</display-name>
<servlet-name>Redirect</servlet-name>
<servlet-class>com.example.servlet.RedirectServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Redirect</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
원하는 경우 소스를 수정하지 않고도 기본 webapp를 설정할 수 있도록 초기화 매개 변수를 허용하도록 RedirectServlet을 쉽게 수정할 수 있습니다.
이 작업을 수행하는 데 부정적인 영향이 있는지 확실하지 않지만 테스트 한 결과 작동하는 것 같습니다.
context.xml 구성이 작동하지 않았습니다. Tomcat 6.0.29는 docBase가 appBase에 있다고 불평합니다. ... Tomcat 5의 경우 실제로 작동했습니다.
따라서 한 가지 해결책은 응용 프로그램을 ROOT 폴더에 넣는 것입니다.
Another very simple solution is to put an index.jsp to ROOT that redirects to my application like this: response.sendRedirect("/MyApplicationXy");
Best Regards, Jan
I've got a problem when configured Tomcat' server.xml
and added Context element. He just doesn't want to use my config: http://www.oreillynet.com/onjava/blog/2006/12/configuration_antipatterns_tom.html
If you're in a Unix-like
system:
mv $CATALINA_HOME/webapps/ROOT $CATALINA_HOME/webapps/___ROOT
ln -s $CATALINA_HOME/webapps/your_project $CATALINA_HOME/webapps/ROOT
Done.
Works for me.
Ultimate way to change tomcat root application. Tested on Tomcat 7 and 8.
Move to the tomcat webapps directory:
Example on my machine:
~/stack/apache-tomcat/webapps
Rename, replace or delete ROOT folder. My advice is renaming or create a copy for backup. Example rename ROOT to RENAMED_ROOT:
mv ROOT RENAMED_ROOT
Move war file with your application to tomcat webapps directory (its a directory where was old ROOT folder, on my machine: ~/stack/apache-tomcat/webapps)
War file must have a name ROOT.war. Rename your aplication if it's need: yourApplicationName.war -> ROOT.war
- Restart tomcat. After restart your application will be a root.
I'll look at my docs; there's a way of specifying a configuration to change the path of the root web application away from ROOT (or ROOT.war), but it seems to have changed between Tomcat 5 and 6.
Found this:
http://www.nabble.com/Re:-Tomcat-6-and-ROOT-application...-td20017401.html
So, it seems that changing the root path (in ROOT.xml) is possible, but a bit broken -- you need to move your WAR outside of the auto-deployment directory. Mind if I ask why just renaming your file to ROOT.war isn't a workable solution?
Not a very good solution but one way is to redirect from the ROOT app to YourWebApp. For this you need to modify the ROOT index.html.
<html>
<head>
<title>Redirecting to /YourWebApp</title>
</head>
<body onLoad="javascript:window.location='YourWebApp';">
</body>
</html>
OR
<html>
<head>
<title>Redirecting to /YourWebApp</title>
<meta http-equiv="refresh" content="0;url=YourWebApp" />
</head>
<body>
</body>
</html>
Reference : http://staraphd.blogspot.com/2009/10/change-default-root-folder-in-tomcat.html
In Tomcat 7 (under Windows server) I didn't add or edit anything to any configuration file. I just renamed the ROOT folder to something else and renamed my application folder to ROOT and it worked fine.
참고URL : https://stackoverflow.com/questions/715506/how-to-change-the-root-application
'Programming' 카테고리의 다른 글
OS X에서 sed를 사용한 전체 편집 (0) | 2020.07.04 |
---|---|
JSON을 루비 해시로 변환 (0) | 2020.07.04 |
올바른 개수의 인수 확인 (0) | 2020.07.03 |
Greenlet Vs. (0) | 2020.07.03 |
이메일을 보내는 앱을 개발하고 테스트하는 방법 (테스트 데이터로 다른 사람의 사서함을 채우지 않고)? (0) | 2020.07.03 |