APM ( Apache, PHP, MySQL ) + ZendOptimizer Build and linkage for RHEL 4 Writer : 이경호
목차 1. 시스템구성... - 1-1.1. 개요... - 2-1.1.1. 정의... - 2-1.1.2. 목적... - 2-1.1.3. 환경... - 2-2. 준비사항... - 3-2.1. 필수설치프로그램... - 3-2.2. APM 서버구축을위한준비... - 3-2.2.1. APM 서버정의... - 3-3. 다운로드및압축해제... - 4-4. MySQL 설치... - 6-5. Apache2 설치... - 9-6. PHP 5.3 설치... - 10-7. Zend Optimizer 설치... - 11-8. APM + ZendOptimizer 연동확인... - 12-9. Apache 데몬서비스등록... - 15-10. APM 다운받는곳... - 19-11. 참고자료... - 26 - - 1 -
1. 시스템구성 1.1. 개요 1.1.1. 정의 - VMware 7 을이용 RHEL4 OS 에 APM 서버를구축및연동 1.1.2. 목적 - APM 서버구축및연동가이드를작성합니다. 1.1.3. 환경 - Windows OS : Windows 7 Ultimate K (x64) - Linux OS : Red Hat Enterprise Linux 4 (x32) - Virtual machine : Vmware 7 - Process : Intel Core i5 CPU M 460 @ 2.53GHz - memory : 4G - IP : 192.168.111.10-2 -
2. 준비사항 2.1. 필수설치프로그램 Program Version Usage VMware 7 가상머신설치 Xmanager 4 Shell, OUI, FTP 지원 RHEL4 OS machine 2.6.9 실습리눅스 OS 2.2. APM 서버구축을위한준비 2.2.1. APM 서버정의 - 동적인웹서버를구축하는데필요한 Apache 웹서버와, 웹서버의데이터베이스를관리하는 MySQL, 웹서버와데이터베이스사이를연동해주는 PHP, 이 PHP 코드를빠른속도로실행되도록도와주는 ZendOptimizer를 APM 서버라부른다. - 3 -
3. 다운로드및압축해제 [ 설명 ] /usr/local/src 디렉토리에 Apache2(http-2.2.17) 다운받습니다. [root@gz src]# wget http://apache.naggo.co.kr//httpd/httpd-2.2.17.tar.gz --23:02:17-- http://apache.naggo.co.kr//httpd/httpd-2.2.17.tar.gz => `httpd-2.2.17.tar.gz' Resolving apache.naggo.co.kr... 119.194.198.205 Connecting to apache.naggo.co.kr 119.194.198.205 :80... connected. HTTP request sent, awaiting response... 200 OK Length: 6,597,991 (6.3M) [application/x-gzip] 100%[==================================================== ======================================================== ========================>] 6,597,991 5.52M/s 23:02:19 (5.51 MB/s) - `httpd-2.2.17.tar.gz' saved [6597991/6597991] [ 설명 ] /usr/local/src 디렉토리에 MySQL 5.1 다운받습니다. 5.5버전은 Cmake 로설치해야하므로좀복잡합니다. 5.1버전으로설치하겠습니다. [root@gz src]# wget http://www.mysql.com/get/downloads/mysql-5.1/mysql- 5.1.54.tar.gz/from/http://mirror.khlug.org/mysql/ --23:04:42-- http://www.mysql.com/get/downloads/mysql-5.1/mysql- 5.1.54.tar.gz/from/http://mirror.khlug.org/mysql/ => `index.html' Resolving www.mysql.com... 213.136.52.29 Connecting to www.mysql.com 213.136.52.29 :80... connected. HTTP request sent, awaiting response... 302 Found Location: http://mirror.khlug.org/mysql/downloads/mysql-5.1/mysql-5.1.54.tar.gz [following] --23:04:43-- http://mirror.khlug.org/mysql/downloads/mysql-5.1/mysql- 5.1.54.tar.gz => `mysql-5.1.54.tar.gz' Resolving mirror.khlug.org... 163.180.114.72 Connecting to mirror.khlug.org 163.180.114.72 :80... connected. - 4 -
HTTP request sent, awaiting response... 200 OK Length: 23,672,236 (23M) [application/x-gzip] 100%[==================================================== ======================================================== ========================>] 23,672,236 9.63M/s 23:04:46 (9.61 MB/s) - `mysql-5.1.54.tar.gz' saved [23672236/23672236] [ 설명 ] /usr/local/src 디렉토리에 PHP 다운받습니다. [root@gz src]# wget http://kr2.php.net/get/php-5.3.5.tar.gz/from/this/mirror --23:10:58-- http://kr2.php.net/get/php-5.3.5.tar.gz/from/this/mirror => `mirror' Resolving kr2.php.net... 211.234.110.150 Connecting to kr2.php.net 211.234.110.150 :80... connected. HTTP request sent, awaiting response... 302 Found Location: http://kr2.php.net/distributions/php-5.3.5.tar.gz [following] --23:10:58-- http://kr2.php.net/distributions/php-5.3.5.tar.gz => `php-5.3.5.tar.gz' Connecting to kr2.php.net 211.234.110.150 :80... connected. HTTP request sent, awaiting response... 200 OK Length: 14,105,504 (13M) [application/x-tar] 100%[==================================================== ======================================================== ========================>] 14,105,504 8.42M/s 23:11:00 (8.42 MB/s) - `php-5.3.5.tar.gz' saved [14105504/14105504] [ 설명 ] /usr/local/src 디렉토리에 Zend Optimizer(3.3.9) 다운받습니다. [root@gz src]# wget http://pds18.egloos.com/pds/201102/02/34/zendoptimizer- 3.3.9-linux-glibc23-i386.tar.gz --23:11:48-- http://pds18.egloos.com/pds/201102/02/34/zendoptimizer-3.3.9- linux-glibc23-i386.tar.gz => `ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz' - 5 -
Resolving pds18.egloos.com... 211.234.242.176 Connecting to pds18.egloos.com 211.234.242.176 :80... connected. HTTP request sent, awaiting response... 200 OK Length: 3,127,521 (3.0M) [application/x-gzip] 100%[==================================================== ======================================================== ========================>] 3,127,521 8.65M/s 23:11:49 (8.65 MB/s) - `ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz' saved [3127521/3127521] [ 설명 ] 4개의압축파일모두압축해제합니다. [root@gz src]# tar zxf httpd-2.2.17.tar.gz [root@gz src]# tar zxf mysql-5.1.54.tar.gz [root@gz src]# tar zxf php-5.3.5.tar.gz [root@gz src]# tar zxf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz 4. MySQL 설치 [ 설명 ] rpm 으로설치되어있는지확인후있을경우제거합니다. [root@gz src]# rpm -qa grep 'mysql' mysql-4.1.12-3.rhel4.1 mysqlclient10-3.23.58-4.rhel4.1 [root@gz src]# rpm -e --nodeps mysql-4.1.12-3.rhel4.1 [root@gz src]# rpm -e --nodeps mysqlclient10-3.23.58-4.rhel4.1 [ 설명 ] mysql 유저를생성합니다. [root@gz src]# groupadd mysql [root@gz src]# useradd mysql -g mysql -d /home/mysql [ 설명 ] 압축해제한디렉토리로이동합니다. [root@gz src]# cd mysql-5.5.1-6 -
[ 설명 ] configure 스크립트를실행합니다. configure 스크립트는현재사용되는 OS의종류, 커널버전, 컴파일러의종류및버전, 그리고기타여러가지시스템의환경을알아낸뒤에시스템에적당한환경파일을생성합니다. 경로는 /usr/local/mysql, DB디렉토리는 /usr/local/mysql/data, 언어는기본은 utf8로그외나머지도사용할수있도록, Apache와연동되도록옵션설정합니다. [root@gz mysql-5.1.54]#./configure --prefix=/usr/local/mysql -- localstatedir=/usr/local/mysql/data --with-charset=utf8 --with-extra-charsets=all -- with-pthread --enable-thread-safe-client ---- 생략 ---- Thank you for choosing MySQL! Remember to check the platform specific part of the reference manual for hints about installing MySQL on your platform. Also have a look at the files in the Docs directory. [ 설명 ] make 컴파일과정이성공적으로완료되면 make install 프로그램설치합니다. 오래걸립니다. 인내심을가지고기다리면완료됩니다. [root@gz mysql-5.1.54]# make && make install [ 설명 ] 기본데이터베이스를생성합니다. [root@gz mysql-5.1.54]# cd /usr/local/mysql/bin/ [root@gz bin]#./mysql_install_db --user=mysql Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER! To do so, start the server, then issue the following commands: /usr/local/mysql/bin/mysqladmin -u root password 'new-password' - 7 -
/usr/local/mysql/bin/mysqladmin -u root -h Gz password 'new-password' Alternatively you can run: /usr/local/mysql/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/mysql/bin/mysqlbug script! [ 설명 ] /usr/local/mysql/ 디렉토리및파일의소유주를 root로변경하고데이터베이스 /data/ 디렉토리는 mysql 소유주로변경합니다. [root@gz bin]# chown -R root /usr/local/mysql/ [root@gz bin]# chown -R mysql /usr/local/mysql/data/ [ 설명 ] mysql 데몬실행합니다. 보통설치된디렉토리안 /bin 디렉토리에있습니다. [root@gz bin]#./mysqld_safe --user=mysql & [1] 10570 [ 설명 ] mysql 프로세스확인합니다. [root@gz bin]# ps -ef grep -v grep grep mysql root 10570 30342 0 03:51 pts/3 00:00:00 /bin/sh./mysqld_safe -- user=mysql mysql 10621 10570 0 03:51 pts/3 00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --logerror=/usr/local/mysql/data/gz.err --pid-file=/usr/local/mysql/data/gz.pid - 8 -
[ 설명 ] 접속테스트합니다. [root@gz ~]# /usr/local/mysql/bin/mysql -uroot mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.54 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> quit Bye 5. Apache2 설치 [ 설명 ] 압축해제된디렉토리로이동합니다. [root@gz ~]# cd /usr/local/src/httpd-2.2.17 [ 설명 ] rpm 으로설치되어있는지확인후있을경우제거합니다. [root@gz httpd-2.2.17]# rpm -qa grep httpd [ 설명 ] configure 스크립트를실행합니다. 경로는 /usr/local/apache 로, DSO 방식으로 PHP 모듈이사용될수있게설정합니다. [root@gz httpd-2.2.17]#./configure --prefix=/usr/local/apache --enablemodules=so --enable-mods-shared=most [ 설명 ] make 컴파일과정이성공적으로완료되면 make install 프로그램설치합니다. 오래걸립니다. 인내심을가지고기다리면완료됩니다. [root@gz httpd-2.2.17]# make && make install - 9 -
6. PHP 5.3 설치 [ 설명 ] 압축해제된디렉토리로이동합니다. [root@gz ~]# cd /usr/local/src/php-5.3.5 [ 설명 ] configure 스크립트를실행합니다. [root@gz php-5.3.5]#./configure --with-apxs2=/usr/local/apache/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-config-file-path=/usr/local/apache/conf \ --with-exec-dir=/usr/apache/bin --- 생략 --- +----------------------------------------------------------------------------+ License: This software is subject to the PHP License, available in this distribution in the file LICENSE. By continuing this installation process, you are bound by the terms of this license agreement. If you do not agree with the terms of this license, you must abort the installation process at this point. +----------------------------------------------------------------------------+ Thank you for using PHP. [ 설명 ] make 컴파일과정이성공적으로완료되면 make install 프로그램설치합니다. 오래걸립니다. 인내심을가지고기다리면완료됩니다. [root@gz php-5.3.5]# make && make install [ 설명 ] httpd.conf 파일설정합니다. [root@gz php-5.3.5]# cd /usr/local/apache/conf/ [root@gz conf]# vi httpd.conf Listen 80 - 아파치웹서버의포트를설정합니다. ServerName 192.168.111.10 - 서버의도메인이름을적습니다. 도메인이없을경우 IP를입력해도됩니다 DocumentRoot "/usr/local/apache/htdocs" - 10 -
- URL상의서버 root문서가위치하는디렉토리를적습니다. DirectoryIndex index.html index.html.var - 디렉토리의인덱스파일 ( 처음열리는파일 ) 로사용할파일이름을적습니다. AddType application/x-httpd-php.php.htm.html.inc.php5.php4 AddType application/x-httpd-php-source.phps - 이부분은아래내용에추가하시면됩니다. PHP 환경설정하는부분입니다. LoadModule php5_module modules/libphp5.so - DSO support 항목에서아래모듈부분이활성화되었는지확인합니다. - 없을경우 PHP만재설치해야합니다. [ 설명 ] php.ini 환경설정파일을복사합니다. [root@gz conf]# cd /usr/local/src/php-5.3.5 [root@gz php-5.3.5]# cp php.ini-production /usr/local/apache/conf/php.ini 7. Zend Optimizer 설치 [ 설명 ] 압축해제된디렉토리로이동합니다. [root@gz src]# cd ZendOptimizer-3.3.9-linux-glibc23-i386 [ 설명 ] PHP 버전을확인합니다. [root@gz ZendOptimizer-3.3.9-linux-glibc23-i386]# php -v PHP 5.3.5 (cli) (built: Feb 1 2011 04:40:10) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies [ 설명 ] ZendOptimizer 5.2 버전을설치합니다. [root@gz ZendOptimizer-3.3.9-linux-glibc23-i386]# cd data/5_2_x_comp/ [root@gz 5_2_x_comp]# ls ZendOptimizer.so [root@gz 5_2_x_comp]# cp ZendOptimizer.so /usr/local/apache/lib/ [root@gz 5_2_x_comp]# cd /usr/local/apache/bin/ [root@gz bin]# find /usr -name 'php.ini' -type f /usr/local/apache/conf/php.ini [root@gz bin]# vi /usr/local/apache/conf/php.ini - 11 -
[Zend] zend_optimizer.version=3.3.9 zend_extension=/usr/local/apache/lib/zendoptimizer.so [ 설명 ] PHP 버전을확인합니다. [root@gz bin]# php -v Zend Optimizer requires Zend Engine API version 220060519. The Zend Engine API version 220090626 which is installed, is newer. Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Optimizer. PHP 5.3.5 (cli) (built: Feb 1 2011 04:40:10) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies 8. APM + ZendOptimizer 연동확인 [ 설명 ] Apache 재가동및프로세스확인합니다. Restart 또는 stop, start로합니다. [root@gz bin]#./apachectl restart [root@gz bin]# ps -ef grep -v grep grep apache root 1893 1 1 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 1894 1893 0 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 1895 1893 0 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 1896 1893 0 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 1897 1893 0 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start daemon 1898 1893 0 05:19? 00:00:00 /usr/local/apache/bin/httpd -k start [ 설명 ] DNS 설정후연결테스트확인합니다. [root@gz bin]# vi /etc/resolv.conf nameserver 192.168.111.10 [root@gz bin]# ps -ef grep -v grep grep named root 3573 1 0 12:02? 00:00:00./named - 12 -
[ 설명 ] WEB 문서를생성합니다. [root@gz bin]# cd /usr/local/apache/htdocs/ [root@gz htdocs]# vi test.php <?php phpinfo();?> [ 설명 ] WEB 브라우저를이용하여정상적으로가동되는지확인합니다. DNS에 Gz.pe.kr zone 파일이 192.168.111.10 으로되어있습니다. 그래서아래와같은화면이나올수있습니다. 예1 ) http://localhost/test.php 예2 ) http://192.168.111.10/test.php 예3 ) http://gz.pe.kr/test.php - 13 -
- 14 -
9. Apache 데몬서비스등록 [ 설명 ] 리눅스에서서비스를등록하고자동으로실행시켜주면리부팅되도계속띄울수있습니다. httpd 스크립트를만든후 chkconfig 명령어를이용해서서비스에등록하도록하겠습니다. [root@gz etc]# cd /etc/rc.d/init.d [root@gz init.d]# vi httpd #!/bin/bash # # Startup script for the Apache Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /usr/local/apache2/logs/httpd.pid # config: /usr/local/apache2/conf/httpd.conf # Source function library.. /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then fi. /etc/sysconfig/httpd # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache/bin/apachectl // apache 설치한디렉토리를적습니다. httpd=/usr/local/apache/bin/httpd pid=$httpd/logs/httpd.pid prog=httpd - 15 -
RETVAL=0 # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting $prog: " daemon $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid } reload() { echo -n $"Reloading $prog: " killproc $httpd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; - 16 -
stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f $pid ] ; then stop start fi ;; reload) reload ;; graceful help configtest fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start stop restart condrestart reload status" echo $" fullstatus graceful help configtest}" exit 1 esac exit $RETVAL [ 설명 ] 서비스를등록하면서레벨과부팅시시작할수있게모두활성화합니다. [root@gz init.d]# chkconfig --add httpd [root@gz init.d]# chkconfig --level 2345 httpd on - 17 -
[root@gz init.d]# chkconfig --list grep httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@gz init.d]# setup - 18 -
10. APM 다운받는곳 [ 설명 ] Apache 받는곳입니다. [ 설명 ] httpd.apache.org 접속 Download 클릭합니다. [ 설명 ] Unix Source 클릭합니다. - 19 -
[ 설명 ] MySQL 받는곳입니다. [ 설명 ] http://www.mysql.com/ 접속 Downloads (GA) 클릭합니다. [ 설명 ] MySQL Community Server 아래에 DOWNLOAD 클릭합니다. - 20 -
[ 설명 ] 우측에 Locking for previous GA versions? 다른버전보기클릭합니다. [ 설명 ] Source Code 선택후 Generic Linux Download 클릭합니다. - 21 -
[ 설명 ] 계정이없는경우 No thanks, just take me to the downloads! 클릭합니다. [ 설명 ] HTTP / FTP 클릭합니다. - 22 -
[ 설명 ] PHP 다운받는곳입니다. [ 설명 ] www.php.net 접속후 downloads 클릭합니다. [ 설명 ] Source Code 에서.gz 클릭합니다. - 23 -
[ 설명 ] kr.php.net 또는 kr2.php.net 클릭합니다. [ 설명 ] ZendOptimizer 다운받는곳입니다. [ 설명 ] www.zend.com/en/ 접속후 Downloads 클릭합니다. - 24 -
[ 설명 ] ZendOptimizer Download 클릭합니다. [ 설명 ] 32bit, 64bit 중맞는것을클릭합니다. - 25 -
11. 참고자료 참고자료서진수강사님 아이티윌오라클전문가과정 17기우재남저자 Red Hat Fedora 리눅스서버 & 네트워크 http://calmmass.tistory.com Google 검색 - 26 -