Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.
1. tomcat7 설치
sudo apt-get install tomcat7 tomcat7-admin하면 /usr/share/tomcat7에 설치됨
설치후에 http://localhost:8080/하면 It works !페이지가 보인다.
이때.
tomcat home은 /usr/share/tomcat7
tomcat 설정은 /etc/tomcat7
tomcat 로그는 /var/log/tomcat7
tomcat document root directory는 /var/lib/tomcat7/webapps에 있다.
* tomcat기동 : service tomcat7 start
* tomcat다운 : service tomcat7 stop
* 설치중 오류발생시 systemctl status tomcat7.service를 실행하여 확인후 조치한다.
root@gsda1:/var/lib/dpkg/info# systemctl status tomcat7.service [0m tomcat7.service - LSB: Start Tomcat. Loaded: loaded (/etc/init.d/tomcat7; bad; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2017-05-02 07:50:08 UTC; 51s ago Docs: man:systemd-sysv-generator(8) Process: 925 ExecStart=/etc/init.d/tomcat7 start (code=exited, status=1/FAILURE) May 02 07:50:08 sda1 systemd[1]: Starting LSB: Start Tomcat.... May 02 07:50:08 sda1 tomcat7[925]: * no JDK or JRE found - please set JAVA_HOME May 02 07:50:08 sda1 systemd[1]: tomcat7.service: Control process exited, code=exited status=1 May 02 07:50:08 sda1 systemd[1]: Failed to start LSB: Start Tomcat.. May 02 07:50:08 sda1 systemd[1]: tomcat7.service: Unit entered failed state. May 02 07:50:08 sda1 systemd[1]: tomcat7.service: Failed with result 'exit-code'. root@gsda1:/var/lib/dpkg/info# service tomcat7 start Job for tomcat7.service failed because the control process exited with error code. See "systemctl status tomcat7.service" and "journalctl -xe" for details.
* JAVA_HOME이 설정되어 있는데도 불구하고 위오아 같은 오류가 발생하면 http://zipeya.tistory.com/entry/ubuntu-1404-LTS%EC%97%90-tomcat7-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0 를 참조하여
vi /etc/default/tomcat7하여 기동스크립트의 JAVA_HOME값을 설정하여 준다.
그리고 sudo service tomcat7 start 로 tomcat을 재기동 해준다.
2. mod_jk 설치
sudo apt-get install libapache2-mod-jk로 설치하면 설치후 /etc/apache2/mods-available에 자동으로 들어감
3. workers.properties 설정
sudo vi /etc/libapache2-mod-jk/workers.properties 해서 아래의 색상이 있는 부분을 적절하게 수정한다.
-----------------------------------------------------------------------
# OPTIONS ( very important for jni mode )
#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/share/tomcat7
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/java-8-oracle
#
# You should configure your environment slash... ps= on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
...
....
....
....
#
# The workers that your plugins should create and work with
#
worker.list=ajp13_worker
-----------------------------------------------------------------------------------------
4. tomcat의 server.xml파일 수정
sudo vi /var/lib/tomcat7/conf/server.xml
6. tomcat manager및 host-manager 화면 접근방법
가. /etc/tomat7/tomcat-users.xml에서 주석으로 막혀있는 사용자및 패스워드 설정에 대한 주석을 제거하고
manager화면접근을 위해서
<role rolename="manager-gui"/>와 <user username="admin" password="admin" roles="manager-gui"/>를 추가하고
host-manager에 접근하기 위해서
<role rolename="admin-gui"/>와 <user username="admin" password="admin" roles="admin-gui"/>를 추가하고
저장한다.
나. service tomcat7 restart하여 반영하여 준다.
다. http://localhost:8080/manager/html/로 접근하여 id및 패스워드를 입력한다.
------------------------/etc/tomcat7/tomcat-users.xml--------------------------
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
-->
<!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<!-- -->
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="admin" password="admin" roles="manager-gui"/>
<user username="admin" password="admin" roles="admin-gui"/>
<!---->
</tomcat-users>