CentOS 6.4 Mysql 5.6 + httpd 2.4.9 + php 5.5.10 + Tomcat 8.0 설치
리눅스/설치Ⅰ. 설치 전 준비
yum -y ?disablerepo=\* ?enablerepo=c6-media install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool libtool-libs openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison
yum groupinstall "Development Tools"
yum -y install gd gd2 gd-devel gd2-devel wget pcre openssl* perl libaio
- Download
http://dev.mysql.com/downloads/mysql/#downloads
Generic Linux (Architecture Independent), Compressed TAR Archive download
apr: http://apache.mirror.cdnetworks.com/apr/apr-1.6.2.tar.gz
apr-iconv: http://apache.mirror.cdnetworks.com/apr/apr-iconv-1.2.1.tar.gz
apr-util: http://apache.mirror.cdnetworks.com/apr/apr-util-1.6.0.tar.gz
apache: http://apache.mirror.cdnetworks.com/httpd/httpd-2.4.27.tar.gz
pcre: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
php : http://www.php.net/downloads.php#v5
http://kr1.php.net/get/php-5.5.10.tar.gz/from/this/mirror
libiconv : http://www.gnu.org/software/libiconv/#downloading
libmcrypt : http://sourceforge.net/projects/mcrypt/files/Libmcrypt/
mhash : http://mhash.sourceforge.net/
mcrypt : http://sourceforge.net/projects/mcrypt/
ImageMagick: http://www.imagemagick.org/script/download.php
imagick: http://pecl.php.net/package/imagick
Tomcat 8.0 : http://tomcat.apache.org/download-80.cgi
Tomcat Native: http://tomcat.apache.org/download-native.cgi
Tomcat Connector : http://tomcat.apache.org/download-connectors.cgi
jdk : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Ⅱ. MySQL
1. 기존 mysql 제거
yum erase mysql-libs
2. 의존성 패키지 설치
yum install cmake.x86_64
yum install ncurses-devel.x86_64
3. 컴파일
cmake -DCMAKE_INSTALL_PREFIX=/home/mysql \
-DMYSQL_DATADIR=/home/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all
make; make install
4. 환경 설정
cp /home/mysql/support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
다음 항목을 [mysqld] 영역에 추가
########################
basedir = /home/mysql
datadir = /home/mysql/data
port = 3306
server_id = 1
socket = /tmp/mysql.sock
explicit_defaults_for_timestamp=true
########################
5. 사용자 추가 및 DB 설치
groupadd mysql
useradd -r -g mysql mysql
cd /home
chown -R mysql:mysql mysql
cd mysql
scripts/mysql_install_db \
--user=mysql \
--datadir=/home/mysql/data \
--basedir=/home/mysql
6. MySQL 시동파일 구성 및 시작
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
7. root 패스워드 및 보안 설정
/home/mysql/bin/mysql_secure_installation
8. 리눅스 시작시 mysql 구동되도록 설정
chkconfig --add mysqld
chkconfig mysqld on
Ⅲ. Tomcat 8 설치
1. apr 1.6.2 설치
tar zxvf apr-1.6.2.tar.gz
cd apr-1.6.2
./configure --prefix=/usr/local/apr
make
make install
2. apr-iconv 설치
tar zxvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install
3. apr-util 설치
tar zxvf apr-util-1.6.0.tar.gz
cd apr-util-1.6.0
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv
make
make install
4. jdk 설치
rpm -ivh jdk-7u45-linux-x64.rpm
5. Tomcat 8.0 설치
tar zxvf apache-tomcat-8.5.20.tar.gz
mv apache-tomcat-8.5.20 /usr/local/
tar xvzf ../down/tomcat-native-1.2.12-src.tar.gz
cd tomcat-native-1.2.12-src/jni/native/
./configure --with-apr=/usr/local/apr --with-java-home=/usr/java/jdk1.8.0_144/ --libdir=/usr/local/lib64
make
make install
a. 환경구성
vi /etc/profile 파일의 마지막에 다음 행 추가
export LD_LIBRARAY_PATH=/usr/local/apr/lib
export JAVA_HOME=/usr/java/jdk1.8.0_144
export TOMCAT_HOME=/usr/local/tomcat
export PATH=$JAVA_HOME/bin:$TOMCAT_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
b. 설정 확인을 위해 다음 명령 실행
# source /etc/profile
# java -version
************* 다음 내용이 출력되면 성공 ***************************
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
*****************************************************************
c. 방화벽 포트를 오픈
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
service iptables save
service iptables restart
d. tomcat 시작/정지
startup.sh
# tomcat 시작
shutdown.sh
# Tomcat 정지
e. 테스트
http://server-ip:8080/
f. 구동파일 생성
vi /etc/init.d/tomcat
다음 내용을 추가
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
export JAVA_HOME=/usr/java/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=/usr/local/apache-tomcat-8.5.20
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
Ⅳ. apache 설치
1. pcre 설치
pcre-8.41.tar.gz
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41/
./configure --libdir=/usr/local/lib64
make && make install
ln -s /usr/local/lib64/libpcre.so.1 /lib
2. apache 설치
tar xvzf httpd-2.4.27.tgz
cd httpd-2.4.27
groupadd apache
useradd -g apache apache
./configure --prefix=/usr/local/apache \
--enable-authn-alias \
--enable-cache \
--enable-file-cache \
--enable-mem-cache \
--enable-disk-cache \
--enable-mods-shared=most \
--enable-proxy=shared \
--enable-proxy-ajp=shared \
--enable-proxy-ajp=shared \
--enable-dav=shared \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-util/ \
--enable-ssl \
--enable-dav \
--enable-cgi \
--with-mpm=event \
--enable-cgid \
--enable-vhost-alias \
--enable-rewrite \
--enable-forward=shared \
--enable-proxy-connect=shared \
--enable-proxy-http=shared \
--enable-deflate=shared \
--enable-so \
--enable-headers=shared \
--enable-include=shared \
--enable-rewrite=shared
make&&make install
3. Apache 사용자 지정을 위해 /usr/local/apache/conf/httpd.conf 파일 수정
User apache
Group apache
4. Apache 시작
/usr/local/apache/bin/apachectl start
테스트
http://server-ip
It Works!가 보이면 정상
5. 구동 파일 설정
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd
다음 5줄을 #을 포함하여 위 파일의 상단부 #!/bin/bash 다음에 복사
# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /usr/local/apache/bin/apachectl
# config: /usr/local/apache/conf/httpd.conf
# pidfile: /usr/local/apache/logs/httpd.pid
chkconfig --add httpd
chkconfig httpd on
아파치 재시작
/etc/rc.d/init.d/httpd restart
Ⅴ. php-5.5.10 설치
1. PHP 5 지원 라이브러리 설치
a. libiconv(문자 인코딩 라이브러리)
tar xvzf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
b. libmcrypt(PHP에서 암호화 해독 알고리즘인 mcryp를 사용하기 위해서 설치해야 한다)
tar xvzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install --libdir=/usr/local/lib64
make
make install
cd ../../
c. mhash(hash암호화 알고리즘)
tar xvzf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
d. mcrypt 설치
tar xvzf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
2. php-5.5.10 설치
yum install libxml2-devel bzip2-devel libcurl-devel openldap-devel
tar xvzf php-5.5.10.tar.gz
mysql lib를 64비트로 인식되도록 변경
ln -s /home/mysql/lib /home/mysql/lib64
./configure --prefix=/usr/local/php \
--with-libdir=lib64 \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/home/mysql \
--with-mysqli=/home/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-pear=/usr/share/php \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-maintainer-zts \
--enable-opcache \
--with-curl \
--with-iconv-dir=/usr/local \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-bz2 \
--enable-static \
--enable-intl \
--enable-exif \
--with-pdo-mysql=/home/mysql \
--with-gettext
make
iconv관련 링크에러가 날 경우
vi 로 Makefile 을 열어서
EXTRA_LIBS 를 찾아 -liconv 를 추가
make install
3. php구성 파일 생성
cp -f php.ini-production /usr/local/php/etc/php.ini
4. opcache 활성화
/usr/local/php/etc/php.ini 의 opcache 부분을 아래와 같이 변경
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
;opcache.revalidate_path=0
;opcache.save_comments=1
;opcache.load_comments=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
맨 끝에 다음 내용 추가
zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/opcache.so
Ⅵ. PHP5확장모듈 컴파일 및 설치
1. ImageMagick-6.8.7-3.tar.xz 설치
ImageMagick은 TIFF, JPEG, GIF, PNG, PDF 및 기타 포토 CD 등 89가지 이상의 이미지의 읽기, 쓰기 및 처리하는 데 사용할 수 있는 안정적인 도구 및 개발 키트 세트입니다
tar xvzf ImageMagick-6.8.7-3.tar.gz
cd ImageMagick-6.8.7-3
./configure --libdir=/usr/local/lib64
make
make install
cd ..
2. imagick-3.1.2.tgz 설치
yum -y install gtk2-devel* gtk+extra
tar xvzf imagick-3.1.2.tgz
cd imagick-3.1.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini
에 아래 라인 추가
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/imagick.so
cd ..
3. php
# echo "/usr/local/php/lib" >> /etc/ld.so.conf
# ldconfig
4. php-cgi 프로세스 시작
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
올바른 구분을 시작하기 전에 다음 php-fpm.conf 를 테스트 할 수 있습니다.
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm 실행
5. apache 에서 PHP5 지원
vi /usr/local/apache/conf/httpd.conf
#아래 LoadModule 추가
LoadModule php5_module modules/libphp5.so
#AddType 추가
AddType application/x-httpd-php .php .php3 .inc
AddType application/x-httpd-php-source .phps
아파치 재시작
/usr/local/apache/bin/apachectl restart
libconv 에러 발생시 /usr/local/apache/bin/apachectl 맨 위에 다음 라인 추가
export LD_PRELOAD=/usr/local/lib64/libiconv.so
6. php지원 여부 테스트
cd /usr/local/apache/htdocs
echo "<?php phpinfo(); ?>" > phpinfo.php
http://server-ip/phpinfo.php,정상적으로 출력되는 지 확인
Ⅶ. apache와 tomcat 통합
1. mod_jk 생성
tomcat-connectors-1.2.37-src.tar.gz
tar xvzf tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src/
cd native
./configure --with-apxs=/usr/local/apache/bin/apxs
make
cp ./apache-2.0/mod_jk.so /usr/local/apache/modules/
2. 설정파일 복사
cd ../conf
cp httpd-jk.conf /usr/local/apache/conf/mod_jk.conf
cp workers.properties /usr/local/apache/conf/
a. mod_jk.conf 설정
vi /usr/local/apache/conf/mod_jk.conf
다음 내용 추가:
JkWorkersFile /usr/local/apache/conf/workers.properties
JkLogFile /usr/local/apache/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /servlet/* worker1
JkMount /*.jsp worker1
JkMount /application/* worker1
JkMount /*.do worker1
JkMount /*.class worker1
JkMount /*.jar worker1
########해석#############
1. JkMount 위치는 Tomcat이 해석을 담당, JkUnMount는 반대임
2. JkMount /test/* worker1 의 의미는 test 디렉토리 아래는 Tomcat이 처리를 담당
3. jsp와servlet은 tomcat이 처리, 그 외 그림이나 정적 파일은 Apache가 처리
###################
b. vi /usr/local/apache/conf/workers.properties
다음 내용 추가:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=192.168.1.185
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
c. apache 설정파일 수정
vi /usr/local/apache/conf/httpd.conf
다음 내용 추가:
Include /usr/local/apache/conf/mod_jk.conf
# 위 mod_jk.conf 파일의 맨 위에 아래 라인이 있는 지 확인
#LoadModule jk_module modules/mod_jk.so
d. TOMCAT 설정 변경
cd /usr/local/apache-tomcat-8.5.20/conf
vi server.xml
<Host 를 찾음
(다음과 같음: <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">)
다음 줄에 다음 내용을 추가:
<Context path="" docBase="/usr/local/apache-tomcat-8.5.20/webapps"
debug="0" reloadable="true" crossContext="true"/>
########dobase 경로는 /usr/local/apahce/htdocs 로 변경 가능#####
e. apache와 tomcat을 다시 시작
apache 재시작
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start
tomcat 재시작
startup.sh
이 시점에서,tomcat과 apache 통합 완료!
성공여부 확인 :
/usr/local/apache/logs/mod_jk.log 확인
다음과 같은 라인이 나오면 성공!
[Sun Sep 22 23:21:18 2013][15053:3078219984] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
테스트:
vi /usr/local/apache-tomcat-8.5.20/webapps/test.jsp
다음 내용 추가:
<html>
<h1>JSP test<hr>
<%out.println("Hello World!");%>
</html>
http://server-ip/test.jsp
출력결과: HELLO WORLD
yum -y ?disablerepo=\* ?enablerepo=c6-media install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool libtool-libs openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool-ltdl libtool-ltdl-devel bison
yum groupinstall "Development Tools"
yum -y install gd gd2 gd-devel gd2-devel wget pcre openssl* perl libaio
- Download
http://dev.mysql.com/downloads/mysql/#downloads
Generic Linux (Architecture Independent), Compressed TAR Archive download
apr: http://apache.mirror.cdnetworks.com/apr/apr-1.6.2.tar.gz
apr-iconv: http://apache.mirror.cdnetworks.com/apr/apr-iconv-1.2.1.tar.gz
apr-util: http://apache.mirror.cdnetworks.com/apr/apr-util-1.6.0.tar.gz
apache: http://apache.mirror.cdnetworks.com/httpd/httpd-2.4.27.tar.gz
pcre: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
php : http://www.php.net/downloads.php#v5
http://kr1.php.net/get/php-5.5.10.tar.gz/from/this/mirror
libiconv : http://www.gnu.org/software/libiconv/#downloading
libmcrypt : http://sourceforge.net/projects/mcrypt/files/Libmcrypt/
mhash : http://mhash.sourceforge.net/
mcrypt : http://sourceforge.net/projects/mcrypt/
ImageMagick: http://www.imagemagick.org/script/download.php
imagick: http://pecl.php.net/package/imagick
Tomcat 8.0 : http://tomcat.apache.org/download-80.cgi
Tomcat Native: http://tomcat.apache.org/download-native.cgi
Tomcat Connector : http://tomcat.apache.org/download-connectors.cgi
jdk : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Ⅱ. MySQL
1. 기존 mysql 제거
yum erase mysql-libs
2. 의존성 패키지 설치
yum install cmake.x86_64
yum install ncurses-devel.x86_64
3. 컴파일
cmake -DCMAKE_INSTALL_PREFIX=/home/mysql \
-DMYSQL_DATADIR=/home/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all
make; make install
4. 환경 설정
cp /home/mysql/support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
다음 항목을 [mysqld] 영역에 추가
########################
basedir = /home/mysql
datadir = /home/mysql/data
port = 3306
server_id = 1
socket = /tmp/mysql.sock
explicit_defaults_for_timestamp=true
########################
5. 사용자 추가 및 DB 설치
groupadd mysql
useradd -r -g mysql mysql
cd /home
chown -R mysql:mysql mysql
cd mysql
scripts/mysql_install_db \
--user=mysql \
--datadir=/home/mysql/data \
--basedir=/home/mysql
6. MySQL 시동파일 구성 및 시작
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start
7. root 패스워드 및 보안 설정
/home/mysql/bin/mysql_secure_installation
8. 리눅스 시작시 mysql 구동되도록 설정
chkconfig --add mysqld
chkconfig mysqld on
Ⅲ. Tomcat 8 설치
1. apr 1.6.2 설치
tar zxvf apr-1.6.2.tar.gz
cd apr-1.6.2
./configure --prefix=/usr/local/apr
make
make install
2. apr-iconv 설치
tar zxvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install
3. apr-util 설치
tar zxvf apr-util-1.6.0.tar.gz
cd apr-util-1.6.0
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv
make
make install
4. jdk 설치
rpm -ivh jdk-7u45-linux-x64.rpm
5. Tomcat 8.0 설치
tar zxvf apache-tomcat-8.5.20.tar.gz
mv apache-tomcat-8.5.20 /usr/local/
tar xvzf ../down/tomcat-native-1.2.12-src.tar.gz
cd tomcat-native-1.2.12-src/jni/native/
./configure --with-apr=/usr/local/apr --with-java-home=/usr/java/jdk1.8.0_144/ --libdir=/usr/local/lib64
make
make install
a. 환경구성
vi /etc/profile 파일의 마지막에 다음 행 추가
export LD_LIBRARAY_PATH=/usr/local/apr/lib
export JAVA_HOME=/usr/java/jdk1.8.0_144
export TOMCAT_HOME=/usr/local/tomcat
export PATH=$JAVA_HOME/bin:$TOMCAT_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
b. 설정 확인을 위해 다음 명령 실행
# source /etc/profile
# java -version
************* 다음 내용이 출력되면 성공 ***************************
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
*****************************************************************
c. 방화벽 포트를 오픈
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
service iptables save
service iptables restart
d. tomcat 시작/정지
startup.sh
# tomcat 시작
shutdown.sh
# Tomcat 정지
e. 테스트
http://server-ip:8080/
f. 구동파일 생성
vi /etc/init.d/tomcat
다음 내용을 추가
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
export JAVA_HOME=/usr/java/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=/usr/local/apache-tomcat-8.5.20
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
Ⅳ. apache 설치
1. pcre 설치
pcre-8.41.tar.gz
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41/
./configure --libdir=/usr/local/lib64
make && make install
ln -s /usr/local/lib64/libpcre.so.1 /lib
2. apache 설치
tar xvzf httpd-2.4.27.tgz
cd httpd-2.4.27
groupadd apache
useradd -g apache apache
./configure --prefix=/usr/local/apache \
--enable-authn-alias \
--enable-cache \
--enable-file-cache \
--enable-mem-cache \
--enable-disk-cache \
--enable-mods-shared=most \
--enable-proxy=shared \
--enable-proxy-ajp=shared \
--enable-proxy-ajp=shared \
--enable-dav=shared \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-util/ \
--enable-ssl \
--enable-dav \
--enable-cgi \
--with-mpm=event \
--enable-cgid \
--enable-vhost-alias \
--enable-rewrite \
--enable-forward=shared \
--enable-proxy-connect=shared \
--enable-proxy-http=shared \
--enable-deflate=shared \
--enable-so \
--enable-headers=shared \
--enable-include=shared \
--enable-rewrite=shared
make&&make install
3. Apache 사용자 지정을 위해 /usr/local/apache/conf/httpd.conf 파일 수정
User apache
Group apache
4. Apache 시작
/usr/local/apache/bin/apachectl start
테스트
http://server-ip
It Works!가 보이면 정상
5. 구동 파일 설정
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd
다음 5줄을 #을 포함하여 위 파일의 상단부 #!/bin/bash 다음에 복사
# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /usr/local/apache/bin/apachectl
# config: /usr/local/apache/conf/httpd.conf
# pidfile: /usr/local/apache/logs/httpd.pid
chkconfig --add httpd
chkconfig httpd on
아파치 재시작
/etc/rc.d/init.d/httpd restart
Ⅴ. php-5.5.10 설치
1. PHP 5 지원 라이브러리 설치
a. libiconv(문자 인코딩 라이브러리)
tar xvzf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
b. libmcrypt(PHP에서 암호화 해독 알고리즘인 mcryp를 사용하기 위해서 설치해야 한다)
tar xvzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install --libdir=/usr/local/lib64
make
make install
cd ../../
c. mhash(hash암호화 알고리즘)
tar xvzf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
d. mcrypt 설치
tar xvzf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure --prefix=/usr/local --libdir=/usr/local/lib64
make
make install
cd ..
2. php-5.5.10 설치
yum install libxml2-devel bzip2-devel libcurl-devel openldap-devel
tar xvzf php-5.5.10.tar.gz
mysql lib를 64비트로 인식되도록 변경
ln -s /home/mysql/lib /home/mysql/lib64
./configure --prefix=/usr/local/php \
--with-libdir=lib64 \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/home/mysql \
--with-mysqli=/home/mysql/bin/mysql_config \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-pear=/usr/share/php \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-maintainer-zts \
--enable-opcache \
--with-curl \
--with-iconv-dir=/usr/local \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-bz2 \
--enable-static \
--enable-intl \
--enable-exif \
--with-pdo-mysql=/home/mysql \
--with-gettext
make
iconv관련 링크에러가 날 경우
vi 로 Makefile 을 열어서
EXTRA_LIBS 를 찾아 -liconv 를 추가
make install
3. php구성 파일 생성
cp -f php.ini-production /usr/local/php/etc/php.ini
4. opcache 활성화
/usr/local/php/etc/php.ini 의 opcache 부분을 아래와 같이 변경
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
;opcache.revalidate_path=0
;opcache.save_comments=1
;opcache.load_comments=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
맨 끝에 다음 내용 추가
zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/opcache.so
Ⅵ. PHP5확장모듈 컴파일 및 설치
1. ImageMagick-6.8.7-3.tar.xz 설치
ImageMagick은 TIFF, JPEG, GIF, PNG, PDF 및 기타 포토 CD 등 89가지 이상의 이미지의 읽기, 쓰기 및 처리하는 데 사용할 수 있는 안정적인 도구 및 개발 키트 세트입니다
tar xvzf ImageMagick-6.8.7-3.tar.gz
cd ImageMagick-6.8.7-3
./configure --libdir=/usr/local/lib64
make
make install
cd ..
2. imagick-3.1.2.tgz 설치
yum -y install gtk2-devel* gtk+extra
tar xvzf imagick-3.1.2.tgz
cd imagick-3.1.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini
에 아래 라인 추가
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/imagick.so
cd ..
3. php
# echo "/usr/local/php/lib" >> /etc/ld.so.conf
# ldconfig
4. php-cgi 프로세스 시작
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
올바른 구분을 시작하기 전에 다음 php-fpm.conf 를 테스트 할 수 있습니다.
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm 실행
5. apache 에서 PHP5 지원
vi /usr/local/apache/conf/httpd.conf
#아래 LoadModule 추가
LoadModule php5_module modules/libphp5.so
#AddType 추가
AddType application/x-httpd-php .php .php3 .inc
AddType application/x-httpd-php-source .phps
아파치 재시작
/usr/local/apache/bin/apachectl restart
libconv 에러 발생시 /usr/local/apache/bin/apachectl 맨 위에 다음 라인 추가
export LD_PRELOAD=/usr/local/lib64/libiconv.so
6. php지원 여부 테스트
cd /usr/local/apache/htdocs
echo "<?php phpinfo(); ?>" > phpinfo.php
http://server-ip/phpinfo.php,정상적으로 출력되는 지 확인
Ⅶ. apache와 tomcat 통합
1. mod_jk 생성
tomcat-connectors-1.2.37-src.tar.gz
tar xvzf tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src/
cd native
./configure --with-apxs=/usr/local/apache/bin/apxs
make
cp ./apache-2.0/mod_jk.so /usr/local/apache/modules/
2. 설정파일 복사
cd ../conf
cp httpd-jk.conf /usr/local/apache/conf/mod_jk.conf
cp workers.properties /usr/local/apache/conf/
a. mod_jk.conf 설정
vi /usr/local/apache/conf/mod_jk.conf
다음 내용 추가:
JkWorkersFile /usr/local/apache/conf/workers.properties
JkLogFile /usr/local/apache/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /servlet/* worker1
JkMount /*.jsp worker1
JkMount /application/* worker1
JkMount /*.do worker1
JkMount /*.class worker1
JkMount /*.jar worker1
########해석#############
1. JkMount 위치는 Tomcat이 해석을 담당, JkUnMount는 반대임
2. JkMount /test/* worker1 의 의미는 test 디렉토리 아래는 Tomcat이 처리를 담당
3. jsp와servlet은 tomcat이 처리, 그 외 그림이나 정적 파일은 Apache가 처리
###################
b. vi /usr/local/apache/conf/workers.properties
다음 내용 추가:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=192.168.1.185
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
c. apache 설정파일 수정
vi /usr/local/apache/conf/httpd.conf
다음 내용 추가:
Include /usr/local/apache/conf/mod_jk.conf
# 위 mod_jk.conf 파일의 맨 위에 아래 라인이 있는 지 확인
#LoadModule jk_module modules/mod_jk.so
d. TOMCAT 설정 변경
cd /usr/local/apache-tomcat-8.5.20/conf
vi server.xml
<Host 를 찾음
(다음과 같음: <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">)
다음 줄에 다음 내용을 추가:
<Context path="" docBase="/usr/local/apache-tomcat-8.5.20/webapps"
debug="0" reloadable="true" crossContext="true"/>
########dobase 경로는 /usr/local/apahce/htdocs 로 변경 가능#####
e. apache와 tomcat을 다시 시작
apache 재시작
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start
tomcat 재시작
startup.sh
이 시점에서,tomcat과 apache 통합 완료!
성공여부 확인 :
/usr/local/apache/logs/mod_jk.log 확인
다음과 같은 라인이 나오면 성공!
[Sun Sep 22 23:21:18 2013][15053:3078219984] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
테스트:
vi /usr/local/apache-tomcat-8.5.20/webapps/test.jsp
다음 내용 추가:
<html>
<h1>JSP test<hr>
<%out.println("Hello World!");%>
</html>
http://server-ip/test.jsp
출력결과: HELLO WORLD