Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

개발자인생

JAVA + APACHE + TOMCAT + SVN 설정 본문

IT/CentOS

JAVA + APACHE + TOMCAT + SVN 설정

정석봉 2016. 4. 6. 20:07

#1 JAVA 7 (JDK 1.7) 설치 

http://www.oracle.com/index.html 에 접속 하여 

Downloads > Java for Developers > JAVA Archive 에서 DOWNLOAD버튼 클릭 > Java SE 7 클릭 > Java SE Development Kit 7u80





여기서 Accept License Agreement 선택후 원하는 파일을 다운로드 받을 수 있다. ( 구버전이기때문에 로그인 필요 )

다운받은 파일은 FTP를 이용 하여 파일을 올리고 적당한 위치에서 압출 파일을 해제한다. 

#>tar -zxvf jdk-7u79-linux-x64.tar.gz


압축푼 경로를 기억하고 환경변수를 설정한다. 

#>vi /etc/profile 

맨 밑 하단에 아래와 같이 환경변수를 적용한다. ( 미리 JAVA, 톰켓, 메이븐을 한번에 설정 하였다. )

저장후 

#>source /etc/profile

profile의 수정을 알려준다. 

#>java -version

자바가 잘 설정 되어있는걸 확인 할 수 있다. 


#2 apache 2.2 설치

http://httpd.apache.org/download.cgi#apache22 여기서 직접 다운로드 받아 FTP로 밀어 넣거나 

wget을 이용 하여 받을수 있다. (wget http://mirror.navercorp.com/apache//httpd/httpd-2.2.31.tar.gz)

#>tar -zxvf httpd-2.2.31.tar.gz

명령어를 이용 하여 압축을 풀고 폴더로 이동한다. 

#>./configure --prefix=/home/server/apache --enable-rule=SHARED_CORE --enable-modules=all --enable-mods-shared=most --enable-so --enable-ssl 

명령어를 이용 하여 configure를 진행한다. 진행도중 configure: error: ...No recognized SSL/TLS toolkit detected 같은 오류가 발생하면 

openssl를 설치 하자 

http://www.openssl.org/source/ 여기서 openssl-1.0.2g.tar.gz 을 다운받아 FTP로 밀어 넣거나

wget을 이용 하여 받을수 있다. (wget http://www.openssl.org/source/openssl-1.0.2g.tar.gz)

#>tar -zxvf openssl-1.0.2g.tar.gz

명령어를 이용 하여 압축을 풀고 폴더로 이동한다.

#>./config --prefix=/usr --openssldir=/usr/local/openssl shared

#>make

#>make install

설치 완료후 다시 아파치 폴더로 이동하여 

#>./configure --prefix=/home/server/apache --enable-rule=SHARED_CORE --enable-modules=all --enable-mods-shared=most --enable-so --enable-ssl 

#>make

#>make install


#3 tomcat 7 설치

http://tomcat.apache.org/download-70.cgi 여기서 직접 다운로드 받아 FTP로 밀어 넣거나 

wget을 이용 하여 받을수 있다. (wget http://mirror.navercorp.com/apache/tomcat/tomcat-7/v7.0.68/bin/apache-tomcat-7.0.68.tar.gz)

적당한 위치에 받아 압출을 해제한다. 

#>tar -zxvf apache-tomcat-7.0.68.tar.gz


#4 apache + tomcat 연동

일단 mod_jk.so 파일이 필요하다. 

wget http://apache.tt.co.kr/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz 이용 하여 일단 다운로드 받자

#>tar -zxvf tomcat-connectors-1.2.41-src.tar.gz 

압축을 해제후 폴더로 이동하여 

tomcat-connectors-1.2.41-src/native/ 폴더까지 이동하자. 

#>./configure --with-apxs=/usr/sbin/apxs

오류가 발생 한다면 

#>yum install httpd-devel 

으로 설치 하자 다시 

#>./configure --with-apxs=/usr/sbin/apxs

#>make && make install

설치후 

#>cd apache-2.0/

#>cp mod_jk.so /home/server/apache/modules/

cp명령어를 이용 하여 mod_jk.so파일 복사


apache + tomcat 연동을 위해서 apache홈의 경로에 있는 conf폴더의 httpd.conf를 수정하자

#>vi conf/httpd.conf

ServerName 의 주석을 풀어주고 도메인또는 IP를 입력해주자.

Include conf/extra/httpd-vhosts.conf 는 주석을 풀고 

include conf/extra/httpd-jk.conf 는 추가로 입력해주고 저장한다. 


#>cd conf/extra/ 

로 이동하여 httpd-jk.conf 파일을 생성하자

#>vi httpd-jk.conf


LoadModule jk_module /home/server/apache/modules/mod_jk.so


JkWorkersFile /home/server/apache/conf/extra/workers.properties

JkMountFile /home/server/apache/conf/extra/uriworkermap.properties

JkLogFile /home/server/tomcat7/logs/mod_jk.log

JkLogLevel info

JkLogstampFormat "[%a %b %d %H:%M:%S %Y]"

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

JkRequestLogFormat "%w %V %T" 


를 입력하고 저장하자 (설정에 맞게 경로를 입력하면된다 )


uriworkermap.properties, workers.properties를 생성하자

#>vi uriworkermap.properties


/home/server/tomcat7/webapp/*=lb

/manager/*=lb

/docs/*=lb

/host-manager/*=lb

/index.jsp=lb

!/servlet-examples/*.jpeg=lb 


를 입력하고 저장하자 (설정에 맞게 경로를 입력하면된다 )


#>vi workers.properties


workers.properties

worker.list=tomcat7,tomcat71


# 기본톰켓 

worker.tomcat7.port=8009

worker.tomcat7.host=localhost

worker.tomcat7.type=ajp13


# project 

worker.tomcat71.port=18009

worker.tomcat71.host=localhost

worker.tomcat71.type=ajp13


worker.lb.type=lb

worker.lb.balance_workers=tomcat7 


를 입력하고 저장하자 

worker.list는 설정된 톰켓들의 명칭이다. 



아파치 톰켓 연동은 하나의 아파치에 여려개의 톰켓을 연동 할 수 있다. 

톰켓은 부모가 되는 톰켓에 자식이 되는 톰켓 인스턴스를 여려개 생성하여 아파치와 연동 할 수 있고 독자적으로 실행 할 수도 있다. 


#>vi httpd-vhosts.conf


<VirtualHost *:80>

    DocumentRoot "/home/server/tomcat7/webapps/ROOT"

    ServerName 192.168.0.164


    JkMount /* tomcat71

    JkMount /servlet/* tomcat71


    ErrorLog "/home/server/apache/logs/www.1004fresh.com-error_log"

    CustomLog "/home/server/apache/logs/www.1004fresh.com-access_log" common

</VirtualHost>



이제 톰켓 인스턴스를 만들어보자!!

톰켓  인스턴스는 서버에 여러개의 톰켓을 띄우기 위해서 하는 작업이다. 

본 톰켓이 존재를 하고 서브로 톰켓을 여러개를 만들어 개별로 프로젝트마다 톰켓을 띄울수 있다. 

관리적이 측면에서 좋다 

톰켓 홈 폴더에서 카피 명령어를 이용 하여 서브 톰켓을 만들자 톰켓을 통으로 복사하면 된다. 

#>cp tomcat7 /home/server/tomcat1

복사후 복사한 폴더로 이동하여 필요 없는 폴더및 파일을 삭제 하자 

#>rm -rf LICENSE NOTICE RELEASE-NOTES RUNNING.txt lib

startup.sh, shutdown.sh를 만들어주 자 

#>vi startup.sh

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env bash

export CATALINA_BASE=/home/server/tomcat1

export JAVA_OPTS="-Djava.awt.headless=true -server -Xms1024m -Xmx2048m -XX:NewSize=256m -XX:MaxNewSize=512m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+DisableExplicitGC"

export CATALINA_OPTS="-Denv=product -Denv.servername=projectTomcat"

cd $CATALINA_HOME/bin

./startup.sh

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

#>vi shutdown.sh

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env bash

export CATALINA_BASE=/home/server/tomcat1

cd $CATALINA_HOME/bin

./shutdown.sh

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

생성한 startup.sh, shutdown.sh에 실행 권한을 주자 

#> chmod 711 *.sh


다음으로 server.xml를 수정하자 

#>vi conf/server.xml

포트번호를 8005 -> 18005, 8080 -> 18080, 8443 -> 18443, 8009 -> 18009 로  수정하자 개인에 맞게 수정하면 된다. 

기존 포트번호에 앞에 1을 추가로 붙여주었다 나중에 인스터스를 추가로 했을경우를 생각해서 1, 2, 3, 이런식으로 붙여주면 나중에 1번 서버 2번서버...

기억 하기 편하기 위해서 붙였다 포트 수정은 다른 포트랑 겹치지 않게 알아서 수정 하면 된다. 





'IT > CentOS' 카테고리의 다른 글

간단한 명령어  (0) 2016.04.07
사용자 생성및 su권한 주기  (0) 2016.04.06
Comments