1. 톰켓 다운로드 및 톰켓 이동
wget http://apache.tt.co.kr/tomcat/tomcat-7/v7.0.73/bin/apache-tomcat-7.0.73.tar.gz tar -xvf apache-tomcat-7.0.63.tar.gz mv apache-tomcat-7.0.63/ tomcat
2. 톰켓 등록
cd /etc/rc.d/init.d/ vi tomcat
#!/bin/bash # Startup script for the Tomcat Server # chkconfig: 345 50 50 # description: Tomcat is a Web application server. # processname: java # directory : CATALINA_HOME=/usr/local/tomcat source /etc/profile export CATALINA_HOME=/usr/local/tomcat case "$1" in start) echo "Starting tomcat: " $CATALINA_HOME/bin/startup.sh ;; stop) echo "Shutting down tomcat: " $CATALINA_HOME/bin/shutdown.sh ;; restart) echo "Restarting tomcat: " $CATALINA_HOME/bin/shutdown.sh; $CATALINA_HOME/bin/startup.sh ;; *) echo "Usage: service tomcat {start|stop|restart}" exit 1 esac exit 0
3. 서버 시작시 자동 실행 등록하기
chmod 755 tomcat chkconfig --add tomcat chkconfig --list tomcat
4. 아파치와 톰켓의 연결(jk_mod) 사용(다운로드)
cd /usr/local wget http://apache.tt.co.kr/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz [링크가 안된다면 아래에서 다운로드] tomcat-connectors-1.2.40-src.tar tar -xvf tomcat-connectors-1.2.40-src.tar.gz
5. apxs가 있는지 없는지 확인 (있다면 패스~)
find / -name 'apxs' -print yum install httpd-devel
6.설치 경로확인(대부분 이 경로)
find / -name 'apxs' -print /usr/sbin/apxs
7.make 컴파일을 하기 위해서 “Development Tools”가 필요
yum groupinstall "Development Tools"
8. make 컴파일
cd /usr/local/tomcat-connectors-1.2.40-src/native ./configure --with-apxs=/usr/sbin/apxs./src/httpd-2.2.24/support/apxsmake && make install
9.아파치 경로 확인
find / -name httpd.conf /etc/httpd/conf/httpd.conf
10. 아파치와 톰켓의 연동을 위한 workers.preperties 생성(아파치의 workers의 파일은 tomcat의 8009번 포트와 연결됨.
cd /etc/httpd/conf/ vi workers.properties
11. workers.properties의 내용 입력
workers.tomcat_home="/usr/local/tomcat" workers.java_home="/usr/local/jdk1.7.0_79" ps=/ worker.list=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13
12.생성된 mod_jk.c의 모듈을 이용해서 JKwork에 등록
vi mod_jk.conf
<IfModule mod_jk.c> JkWorkersFile "/etc/httpd/conf/workers.properties" JkLogFile "/usr/local/tomcat/logs/mod_jk.log" JkLogLevel info JkAutoAlias "/usr/local/tomcat/webapps" JkMount /* ajp13 JkMount /*.jsp ajp13 JkMount /servlet/* ajp13 JkMount /examples/*.jsp ajp13 JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" </IfModule>
13.아파치 httpd.conf에 모듈 및 config파일 추가
vi /etc/httpd/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so include conf/mod_jk.conf
14.톰켓 시작
service httpd stop service tomcat stop service httpd start service tomcat start
끝~!
****에러발생시****
만약 mod_jk에러 방생시
[Thu Aug 06 15:20:23 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 [Thu Aug 06 15:20:23 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Thu Aug 06 15:20:23 2015] [error] (13)Permission denied: mod_jk: could not open JkLog file /usr/local/tomcat/logs/mod_jk.log
해결책
1. vi 를 통해 “/etc/selinux/config” 에 접속한다.
2. selinux 를 화면과 같이 disabled 하면 된다.
vi /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
3. 적용하기
setenforce 0