[Tomcat] APM과 tomcat 연동하기 Linux



1. Mysql : mysql-5.1.40.tar.gz

./configure --prefix=/usr/local/mysql --localstatedir=/home/sqldata --enable-assembler --without-debug --with-mysqld-user=mysql --with-charset=utf8 --with-extra-charsets=complex --enable-thread-safe-client


make
make install


cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db
useradd -M mysql

chown -R mysql:mysql /home/sqldata
ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /usr/local/mysql/bin/mysqldump /usr/bin

/usr/local/mysql/bin/mysqld_safe &


/usr/local/mysql/bin/mysqladmin -u root password 'mysql'
접속
/usr/local/mysql/bin/mysql -u root -p
show databases;


* mysql root 암호 변경 => /usr/local/mysql/bin/mysql -p mysql


2. Apache2 : httpd-2.2.14.tar.gz

>> MaxClient 설정
/server/mpm/prefork/prefork.c 파일에서
#define DEFAULT_SERVER_LIMIT 2048(256->2048)

/server/mpm/worker/worker.c 파일에서
#define DEFAULT_SERVER_LIMIT 32(16->32)

# ./configure --prefix=/usr/local/apache2 --enable-so --enable-modules=all --enable-mods-shared=all --enable-ssl --enable-rewrite --enable-cache --enable-disk-cache --enable-mem-cache --with-mpm=worker


# make
# make install

# ln -s /usr/local/apache2/bin/apachectl /usr/bin/apachectl
# ln -s /usr/local/apache2/bin/apxs /usr/bin/apxs


<부팅 시 자동 실행>
# vi /etc/rc.d/rc.local
/usr/local/apache2/bin/apachectl start



3. Tomcat connector : tomcat-connectors-1.2.28-src.tar.gz

# yum install apr*


# cd native
# ./buildconf.sh
# ./configure --with-apxs=/usr/local/apache2/bin/apxs
# make
# make install

/usr/local/apache2/modules/mod_jk.so 파일 생성됨!


4. Apache tomcat : http://jakarta.apache.org/

tar xvfz apache-tomcat-5.5.28.tar.gz
mv apache-tomcat-5.5.28 /usr/local/tomcat


1) JDK6 : jdk-6u16-linux-i586.bin
download : http://java.sun.com -> Download -> Java SE -> Java SE Development Kit (JDK) :: download

# mv jdk-6u16-linux-i586.bin /usr/local
# sh jdk-6u16-linux-i586.bin
yes
# mv jdk1.6.0_16 java

# vi /etc/profile
## for JDK, Tomact, Ant setting ##
export JAVA_HOME=/usr/local/java
export CATALINA_HOME=/usr/local/tomcat
export CLASSPATH=./:$JAVA_HOME/lib/tools.jar:/usr/local/tomcat/common/lib/servlet.jar
export PATH=$PATH:$JAVA_HOME/bin:/usr/local/ant/bin

# . /etc/profile <== 변경 값 읽혀 줌!



2) ant 설치(http://ant.apache.org/bindownload.cgi)
# wget http://apache.mirror.cdnetworks.com/ant/binaries/apache-ant-1.7.1-bin.tar.gz
# tar xvfz apache-ant-1.7.1-bin.tar.gz
# mv apache-ant-1.7.1-bin /usr/local/ant



3) workers.properties 파일 만들기

# vi /usr/local/apache2/conf/workers.properties

아래 내용만 입력 후 저장

#
# @(#)workers.properties
#
# Workers
worker.list=tomcat,wlb,jkstatus

# Tomcat Worker
worker.ajp13.type=tomcat
worker.ajp13.port=8009

# Load Balancer Worker
worker.wlb.type=lb
worker.wlb.balance_workers=tomcat

# Status Worker
worker.jkstatus.type=status

# EOF

 

4) 톰캣의 server.xml 수정
# vi /usr/local/tomcat/conf/server.xml


맨 아래에 기존 <host> 부분 주석처리하고 아래 내용 추가
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

                <Context docBase="/home/www/htdocs" path=""
                 useNaming="true" workDir="/home/www/work"
                 reloadable="true">
                </Context>

      </Host>


<!-- VirtualHost 추가시 -->
      <Host name="jonny.co.kr" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

                <Context docBase="/home/www/jonny.co.kr" path=""
                 useNaming="true" workDir="/home/www/jonny.co.kr/work"
                 reloadable="true">
                </Context>

      </Host>

      <Host name="jcc.kr" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

                <Context docBase="/home/www/jcc" path=""
                 useNaming="true" workDir="/home/www/jcc/work"
                 reloadable="true">
                </Context>

      </Host>
            :
            :

5) httpd.conf 수정
/usr/local/apache2/conf/httpd.conf 설정 파일에 아래의 코드를 추가


# vi /usr/local/apache2/conf/httpd.conf

LoadModule jk_module modules/mod_jk.so


<IfModule mod_jk.c>
    JkWorkersFile conf/workers.properties
</IfModule>

ServerName www.abc.co.kr:80

DocumentRoot "/home/html/www.abc.co.kr/htdocs"

<Directory /home/html/www.abc.co.kr/htdocs>
    Allow from all
</Directory>


RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

RewriteRule CVS/(.*)$ /error/error_404.jsp [PT]


<IfModule mod_jk.c>
JkMount  /*.jsp         tomcat
JkMount  /*.do          tomcat
</IfModule>

<IfModule dir_module>
    DirectoryIndex  index.html index.jsp
</IfModule>

ErrorDocument 403 /error/error_403.jsp
ErrorDocument 404 /error/error_404.jsp
ErrorDocument 500 /error/error_500.jsp

6) vhost.conf 셋팅
# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
        DefaultLanguage     ko
        AddDefaultCharset   UTF-8
        ServerAdmin         test@abc.co.kr

        ServerName          www.abc.co.kr
        ServerAlias         abc.co.kr

        DocumentRoot        /home/html/www.abc.co.kr/htdocs
        DirectoryIndex      index.html index.jsp index.do

        CustomLog           "|/usr/local/apache2/bin/rotatelogs /home/html/www.abc.co.kr/logs/access-%Y-%m-%d.log 86400"
 combined
        ErrorLog            "|/usr/local/apache2/bin/rotatelogs /home/html/www.abc.co.kr/logs/error-%Y-%m-%d.log 86400"

        ErrorDocument           403 /error/error_403.jsp
        ErrorDocument           404 /error/error_404.jsp
        ErrorDocument           500 /error/error_500.jsp
   
    <Directory /home/html/www.abc.co.kr/htdocs>
                Allow from all
    </Directory>
   
    RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^TRACE
        RewriteRule .* - [F]

        # Prevent CVS directory
        RewriteRule CVS/(.*)$ /error/error_404.jsp [PT]
   
    <IfModule mod_jk.c>
                JkMount  /*.jsp         tomcat
                JkMount  /*.do          tomcat
    </IfModule>
</VirtualHost>




덧글

댓글 입력 영역



통계 위젯 (블랙)

029
171
346891

이 이글루를 링크한 사람 (화이트)

2

google

구글_이글루스_사이드