Linux/Unix2019. 2. 1. 03:00

  1. 환경
    1. rhel 6.9
    2. openssl 1.1.0h
    3. apache 2.4.33
    4. tomcat 7.0.88
    5. mysql 5.7
    6. jdk(java) 1.7.8

 

  1. 설치전
    1. 의존성 패키지 설치

]#yum groupinstall "Development tools"

]#yum install expat-devel zlib-devel

 

  1. 설치
    1. openssl

https://www.openssl.org/

위사이트에서 1.1.0h 시리즈 최신버전을 다운 받는다

2018 6 기준 ver 

 

]# tar xvfz openssl-1.1.0h.tar.gz

]# cd openssl-1.1.0h

]# ./config shared --prefix=/usr/local/openssl

]# make

]# make install

]# openssl version


 

  • /usr/local/openssl/bin/openssl: error while loading shared libraries: 

                    libssl.so.1.1: cannot open shared object file: No such file or directory

    • ]# ln -s /usr/local/openssl/lib/libssl.so.1.1 /lib64/libssl.so.1.1
    • ]# ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /lib64/libcrypto.so.1.1

실행했을때 라이브러리 관련 에러 나는 라이브러리를 64밑에 링크로 걸어준다

  • ]# mv /usr/bin/openssl /usr/bin/openssl__
  • ]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

     편의상 기존 명령어를 백업하고 새로운 버전으로 교체한다 (환경변수 새로 지정보다 이방법 추천)

 

  1. apr, apr-util, pcre  버전업되면 안받아질수 있음

wget http://mirror.apache-kr.org//apr/apr-1.6.3.tar.gz

wget http://mirror.apache-kr.org//apr/apr-util-1.6.1.tar.gz

wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

 

  • apr

]# tar xvfz apr-1.6.3.tar.gz

]# cd apr-1.6.3

]# ./configure --prefix=/usr/local/apr

]# make

]# make install

 

  • rm: cannot remove `libtoolT': No such file or directory
    • apr-1.6.3]# cp -arp libtool libtoolT

libtoolT 관련 에러가 나오면 libtooT 복사후에 설치를 한다

 

  • apr-util

]# tar xvfz apr-util-1.6.1.tar.gz

]# cd apr-util-1.6.1

]# ./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-util

]# make

]# make install

 

  • make[1]: *** [xml/apr_xml.lo] 오류 1

make[1]: Leaving directory `/root/source/apr-util-1.6.1'

make: *** [all-recursive] 오류

설치시 위와 같이 에러 나올시 expat-devel 설치

yum install expat-devel

 

  • pcre

]# tar xvfz pcre-8.42.tar.gz

]# cd pcre-8.42

]# ./configure --prefix=/usr/local/pcre

]# make

]# make install

 

  1. Apache

wget http://mirror.navercorp.com/apache//httpd/httpd-2.4.33.tar.gz

 

]# tar xvfz httpd-2.4.33.tar.gz

]# cd httpd-2.4.33

]# ./configure --prefix=/opt/APACHE/httpd2.4 \

--enable-module=so \

--enable-rewrite \

--enable-so \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--with-pcre=/usr/local/pcre \

--enable-mods-shared=all \

--enable-ssl \

--enable-modules=ssl \

--with-ssl=/usr/local/openssl

 

OR

 

]# ./configure --prefix=/opt/APACHE/httpd2.4 --enable-module=so --enable-rewrite --enable-so 

--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 

--enable-mods-shared=all --enable-ssl --enable-modules=ssl --with-ssl=/usr/local/openssl

     그대로 복사시 에러나 날수도 있으니 둘중 적합한거 사용

]# make

]# make install

 


]# /opt/APACHE/httpd2.4/bin/apachectl -V

설치후 버전확인

 

]# /opt/APACHE/httpd2.4/bin/apachectl -t

  • AH00558: httpd: Could not reliably determine the server's fully qualified domain name, 

              using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

아파치 가동전에 테스트 할시 위와 같이 에러 발생시

]# vi /opt/APACHE/httpd2.4/conf/httpd.conf

#ServerName www.example.com:80

---> ServerName www.example.com:80

주석을 풀고 아파치가 정상적으로 가동되는지 확인

 

  1. JDK(JAVA) 설치

]# tar xvfz jdk-7u80-linux-x64.tar.gz

]# mkdir -p /usr/java

]# mv jdk1.7.0_80 /usr/java/jdk1.7.0_80

]# vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.7.0_80

export LD_LIBRARY_PATH=$LD_LIBRAPY_PATH:/usr/local/lib

PATH="$PATH:/usr/java/jdk1.7.0_80/bin"

export PATH=$PATH

환경변수로 추가

]# source /etc/profile

]# java -version

 

  • 기존자바가 설치되어 있으면 먼저 삭제후 설치     

 

 

  1. Tomcat

wget http://mirror.navercorp.com/apache/tomcat/tomcat-7/v7.0.88/bin/apache-tomcat-7.0.88.tar.gz

 

]# tar xvfz apache-tomcat-7.0.88.tar.gz

]# mv apache-tomcat-7.0.88 /usr/local/tomcat

]# vi /usr/local/tomcat/conf/server.xml

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

주석 풀어준다 (7버전부터 주석이 없는게 기본값?)

 

]# /usr/local/tomcat/bin/version.sh

  1. ]# vi /etc/rc.d/init.d/tomcat

 

#!/bin/sh

#startup script for Tomcat

#

# chkconfig: 35 85 15

# description: apache tomcat 7.x

#

# processname: tomcat

#

# Source function library.

export JAVA_HOME=/usr/java/jdk1.7.0_80

export CATALINA_HOME=/usr/local/tomcat

 

#export JAVA_OPTS="-server -Xms512m -Xmx512m -XX:MaxPermSize=256m"

export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin

# See how we were called.

case "$1" in

  start)

  echo -n "Starting tomcat: "

  $CATALINA_HOME/bin/catalina.sh start

  echo

  ;;

  stop)

  echo -n "Shutting down tomcat: "

  $CATALINA_HOME/bin/catalina.sh stop

  echo

  ;;

  restart)

  $0 stop

  sleep 2

  $0 start

  ;;

  *)

  echo "Usage: $0 {start|stop|restart}"

  exit 1

esac

exit 0

service 등록하여 사용할때 이용되는 스크립트

]# chmod 755 /etc/rc.d/init.d/tomcat

 

 

  1. `tomcat-connectors

wget http://apache.tt.co.kr/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.43-src.tar.gz

 

]# tar xvfz tomcat-connectors-1.2.43-src.tar.gz

]# cd tomcat-connectors-1.2.43-src/native/

]# ./configure --with-apxs=/opt/APACHE/httpd2.4/bin/apxs

]# make

]# make install

]# ls -l /opt/APACHE/httpd2.4/modules/mod_jk.so    파일 확인

기본적으로 modules 복사가 되는데 혹시나 없으면 컴파일된것을 직접 modules 복사한다

]# cp -a tomcat-connectors-1.2.43-src/native/apache-2.0/mod_jk.so /opt/APACHE/httpd2.4/modules/

 

]# vi /opt/APACHE/httpd2.4/conf/workers.properties    파일생성

worker.list=worker

worker.worker1.type=ajp13

worker.worker1.host=localhost

worker.worker1.port=8009

내용 추가

 

]# vi /opt/APACHE/httpd2.4/conf/tomcat.conf    파일 생성

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkLogFile logs/mod_jk.log

JkLogLevel info

JkMount /* worker

내용 추가

 

]# vi /opt/APACHE/httpd2.4/conf/httpd.conf

Include conf/tomcat.conf

마지막줄에 추가

 

  1. MySQL 5.7, mysql-connector

wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm

 

]# rpm -ivh mysql80-community-release-el6-1.noarch.rpm

]# yum-config-manager --disable mysql80-community

]# yum-config-manager --enable mysql57-community

]# yum install mysql-community-server

]# yum install mysql-connector-java

]# cp -arp /usr/share/java/mysql-connector-java-5.1.17.jar /usr/local/tomcat/lib/

 

  1. tomcat DBCP

]# vi /usr/local/tomcat/conf/context.xml

<Resource

    name="jdbc/mysql" -->JDBC name

    auth="Container"

    type="javax.sql.DataSource"

    driverClassName="com.mysql.jdbc.Driver"  -->mysql jdbc 드라이브명

    loginTimeout="10"

    maxWait="5000"

    username="testuser" --> DB 유저

    password="1234"     --> DB 패스워드

    testOnBorrow="true"

    url="jdbc:mysql://localhost:3306/test" />

</Context>

내용추가

 

  1. apache + tomcat startup

]# /opt/APACHE/httpd2.4/bin/apachectl start

]# /etc/init.d/tomcat start

  • apache, tocmat 스타트업

 

]# cat /usr/local/tomcat/logs/catalina.out

  • 로그를 확인하여 이상없이 톰캣이 올라온것을 확인 한다

 

]# netstat -atnp

  • netst -atnp으로 톰캣이 mysql 제대로 접속이 되었는지 확인한다
  • Java(tomcat) port 58884 -> mysqld(3306) 연결

 

  • 또는 간단한 소스를 이용하여 tomcat + db연동이 되었는지 확인한다

 

 


Posted by 샤키