DATA 전문가로 가는 길

[Unix/Linux] RHEL4 + Apache2 + PHP5.3 + MySql5.1 +Zend Optimizer 설치 및 구동방법 본문

OS/Server Admin

[Unix/Linux] RHEL4 + Apache2 + PHP5.3 + MySql5.1 +Zend Optimizer 설치 및 구동방법

EstenPark 2010. 11. 17. 17:49
작성자 : 박상수
작성일자 : 2010.11.17
작업환경 : VMware 7 [ RedHat Enterprise Linux 4 ]


1. 다운로드 및 압축 해제 

[설명] 보통 웹사이트에서 다운 받아서 설치하는 경우가 많습니다. 하지만 요즘에는 워낙 좋은 유틸리티가 많아서  wget를 활용해서 각 파일을 다운 받는 연습을 해보겠습니다. 방법은 아주 간단합니다. 실제 웹사이트에 접속해서 다운받는 주소를 여기에 넣어주면 됩니다.

[설명] Apache2(httpd-2.0.64) 다운로드
[2010-11-17 17:39:20]-[root@server102:/usr/local/src]
# wget
http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.0.64.tar.gz
--17:42:26--  http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.0.64.tar.gz
           => `httpd-2.0.64.tar.gz'
Resolving
ftp.kaist.ac.kr... 143.248.234.110
Connecting to
ftp.kaist.ac.kr|143.248.234.110|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: /Apache/httpd/httpd-2.0.64.tar.gz [following]
--17:42:26-- 
http://ftp.kaist.ac.kr/Apache/httpd/httpd-2.0.64.tar.gz
           => `httpd-2.0.64.tar.gz'
Reusing existing connection to
ftp.kaist.ac.kr:80.
HTTP request sent, awaiting response... 200 OK
Length: 6,431,717 (6.1M) [text/plain]
100%[====================================>] 6,431,717    911.17K/s    ETA 00:00
17:42:34 (873.22 KB/s) - `httpd-2.0.64.tar.gz' saved [6431717/6431717]

[설명]
PHP5.3.3 다운로드
[2010-11-17 17:44:37]-[root@server102:/usr/local/src]
# wget http://kr2.php.net/get/php-5.3.3.tar.gz/from/kr.php.net/mirror
--17:45:18--  http://kr2.php.net/get/php-5.3.3.tar.gz/from/kr.php.net/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://kr.php.net/distributions/php-5.3.3.tar.gz [following]
--17:45:19--  http://kr.php.net/distributions/php-5.3.3.tar.gz
           => `php-5.3.3.tar.gz'
Resolving kr.php.net... 115.165.178.40
Connecting to kr.php.net|115.165.178.40|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13,921,529 (13M) [application/x-gzip]
100%[====================================>] 13,921,529   445.18K/s    ETA 00:00
17:45:50 (449.21 KB/s) - `php-5.3.3.tar.gz' saved [13921529/13921529]

[설명] MySQL-5.1 다운로드
[2010-11-17 18:35:07]-[root@server102:/usr/local/src]
# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-community-5.1.52-1.rhel4.src.rpm/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
--20:37:05--  http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-community-5.1.52-1.rhel4.src.rpm/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
           => `index.html'
Resolving dev.mysql.com... 213.136.52.29
Connecting to dev.mysql.com|213.136.52.29|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: ftp://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.1/MySQL-community-5.1.52-1.rhel4.src.rpm [following]
--20:37:06--  ftp://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.1/MySQL-community-5.1.52-1.rhel4.src.rpm
           => `MySQL-community-5.1.52-1.rhel4.src.rpm'
Resolving ftp.iij.ad.jp... 202.232.140.141, 202.232.140.135, 202.232.140.136, ...
Connecting to ftp.iij.ad.jp|202.232.140.141|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/db/mysql/Downloads/MySQL-5.1 ... done.
==> PASV ... done.    ==> RETR MySQL-community-5.1.52-1.rhel4.src.rpm ... done.
Length: 23,183,754 (22M) (unauthoritative)
100%[==============================================================>] 23,183,754   126.95K/s    ETA 00:00

[설명] Zend Optimizer 다운로드(여기서 다운 받으세요.)
ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

[설명] rpm으로 설치 되어있는지 확인 후 있을 경우 제거 합니다.
 패키지 설치 확인 명령어 rpm -qa |grep '패키지명'
[2010-11-18 20:19:36]-[root@server102:/usr/local/src]
# rpm -e mysqlclient10
[2010-11-18 20:20:28]-[root@server102:/usr/local/src]
# rpm -e --nodeps mysql

[설명] src.rpm 파일을 리빌드하는 척 하는 아주 요상한 rpm 구조입니다. 개인적으로 이것 때문에 1시간을 삽질하고 터득 한것은 반드시 생각하고 만들 구조라는 거죠. 뭐 그렇게 좋은 아이디어는 아닌것 같지만 ...
우선 rpm -Uvh로 패키지를 풀면 에러메시지가 나오게 됩니다. 신경 쓰지 않으셔도 되며 tar.gz파일이 있는지 확인 하고 설치를 위해서 복사를 하겠습니다.
[2010-11-18 20:58:30]-[root@server102:/usr/local/src]
# ls
MySQL-community-5.1.52-1.rhel4.src.rpm  httpd-2.0.64.tar.gz  php-5.3.3.tar.gz
[2010-11-18 20:58:30]-[root@server102:/usr/local/src]
# rpm -Uvh MySQL-community-5.1.52-1.rhel4.src.rpm
에러 메시지 나옴 신경 쓰지 마세요.
########################################### [100%]
[2010-11-18 20:58:44]-[root@server102:/usr/local/src]

# cd /usr/src/redhat/
[2010-11-18 20:58:56]-[root@server102:/usr/src/redhat]
# find . -name '*mysql*'
./SPECS/mysql-5.1.52.rhel4.spec
./SOURCES/mysql-5.1.52.tar.gz      

[2010-11-18 20:58:56]-[root@server102:/usr/src/redhat]
# cp ./SOURCES/mysql-* /usr/local/src



2. MySql 5.1 설치 가이드


[설명] 유저를 생성 합니다.
[2010-11-18 21:07:32]-[root@server102:/usr/local/src]
# groupadd mysql
[2010-11-18 21:07:43]-[root@server102:/usr/local/src]
# useradd mysql -g mysql -d /home/mysql

[설명] 압축 해제
[2010-11-18 21:08:14]-[root@server102:/usr/local/src]
# ls
MySQL-community-5.1.52-1.rhel4.src.rpm  mysql-5.1.52.tar.gz
httpd-2.0.64.tar.gz                     php-5.3.3.tar.gz
[2010-11-18 21:11:51]-[root@server102:/usr/local/src]
# tar zxf mysql-5.1.52.tar.gz

[2010-11-18 21:12:43]-[root@server102:/usr/local/src]
# ls
MySQL-community-5.1.52-1.rhel4.src.rpm  mysql-5.1.52         php-5.3.3.tar.gz
httpd-2.0.64.tar.gz                     mysql-5.1.52.tar.gz
[2010-11-18 21:12:55]-[root@server102:/usr/local/src]
# cd mysql-5.1.52
[2010-11-18 21:12:58]-[root@server102:/usr/local/src/mysql-5.1.52]
# ls
BUILD               Makefile.in     configure.in  ltmain.sh   scripts        unittest
CMakeLists.txt      README          dbug          man         server-tools   vio
COPYING             aclocal.m4      depcomp       missing     sql            win
ChangeLog           client          extra         mysql-test  sql-bench      ylwrap
Docs                cmd-line-utils  include       mysys       sql-common     zlib
EXCEPTIONS-CLIENT   config          install-sh    netware     storage
INSTALL-SOURCE      config.guess    libmysql      plugin      strings
INSTALL-WIN-SOURCE  config.sub      libmysql_r    pstack      support-files
Makefile.am         configure       libmysqld     regex       tests
[2010-11-18 21:13:03]-[root@server102:/usr/local/src/mysql-5.1.52]

[설명]
configure를 이용하여 검증 단계를 시작 합니다. 그럼 아래를 내용을 한글로 옮겨 보겠습니다.
기본 설치 디렉토리르는 /usr/local/mysql로 하고 데이터베이스 디렉토리는 /usr/local/mysql/data에 해서 관리, 언어는 euckr 한글, pthread는 음...POSIX thread아닐런지? 마지막으로 "--enable-thread-safe-client" 부분은 꼭 필요한 옵션 사항은 아닙니다. Apache와 연동하기 위해서 사용 합니다.
# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-charset=euckr --with-pthread --enable-thread-safe-client
생략..
config.status: creating include/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands

Thank you for choosing MySQL!                  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(source 컴파일 과정) make install(컴파일이 완료한 것을 실행시켜서 설치)
[2010-11-18 21:22:28]-[root@server102:/usr/local/src/mysql-5.1.52]
# make; make install

[설명] 기본 데이터베이스를 생성 합니다. 처음 설치 했을 경우에는 반드시 아래와 같은 명령어를 수행 하시기 바랍니다.
[2010-11-18 23:37:38]-[root@server102:/usr/local/mysql/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:

[설명] mysql  user를 생성하고 패스워드를 입력 할려면 아래와 같이 하시기 바랍니다.
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h server102 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:

[설명] 중요한 부분이 발견 되었습니다. mysql을 실행하기 위해서는 데몬이 생성되어 있어야 합니다. 다른 얘기로 프로세스가 생성되어 있지 않다면 mysql을 가동 할 수 없습니다.
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!

[설명] 하위 디렉토리 및 파일의 소유주를 root로 변경하고 데이터베이스가 생성될 /data 디렉토리는 mysql 소유주로 생성 하도록 합니다. 보통은 설명과 같이 되어있습니다.
[2010-11-18 23:51:27]-[root@server102:/usr/local/mysql/bin]
# chown -R root /usr/local/mysql/
[2010-11-18 23:56:49]-[root@server102:/usr/local/mysql/bin]
# chown -R mysql /usr/local/mysql/data/

[설명] 통신을 하기 위해서 소켓을 확인 해보고 아래와 같이 패스워드를 넣어 보세요. 꼭 필요하지 않아서 저는 패스 했습니다.
[2010-11-19 00:00:02]-[root@server102:/usr/local/mysql/bin]
# ./mysql_config --socket
/tmp/mysql.sock
[2010-11-19 00:00:58]-[root@server102:/usr/local/mysql/bin]
# ./mysqladmin -u root -h server102 password '12345' -S /tmp/mysql.sock

[설명] 그럼 mysql 데몬을 띄우도록 하겠습니다. 보통 설치된 디렉토리 안에 /bin 디렉토리에 있습니다.
[2010-11-19 00:02:20]-[root@server102:/usr/local/mysql/bin]
# ./mysqld_safe --user=mysql &
[1] 23618

[설명] 데몬을 띄우셨으니 프로세스를 확인 해야 겠죠? 프로세스 확인은 ps명령어로 하고 전체 프로세스가 나오기 때문에 grep 명령어를 이용해서 해당 데몬 명을 입력해서 확인 해보도록 하겠습니다.
[2010-11-19 00:31:53]-[root@server102:~]
# ps -ef |grep -v grep |grep mysql
root     23618  6268  0 00:31 pts/1    00:00:00 /bin/sh ./mysqld_safe --user=mysql
mysql    23669 23618  0 00:31 pts/1    00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/data/server102.err --pid-file=/usr/local/mysql/data/server102.pid

[설명] 마지막으로 접속 테스트를 해보겠습니다. mysql> 이렇게 나오면 아주 잘 설치 하신 겁니다.
[2010-11-19 00:33:12]-[root@server102:~]
# /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 2
Server version: 5.1.52 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


3. Apache 2 설치 가이드

[설명] apache가 패키지로 설치 되어 있는지 확인 후 있을 경우 삭제 하시기 바랍니다. 
[2010-11-18 14:39:49]-[root@server102:/usr/local/src/httpd-2.0.64]
# rpm -qa |grep httpd

[설명] prefix 설치할 경로는 /usr/local/apache하고 -enable에 있는 옵션은 DSO방식으로 PHP 모듈이 사용 될수 있게 하는 것입니다. 만약 아래 옵션에 대한 설정이 잘 못 되어있다면 계속 에러메시지가 발생 됩니다. 끝까지 제대로 설정 되었는지 확인 하는 방법도 같이 해보겠습니다.
[2010-11-18 14:47:00]-[root@server102:/usr/local/src/httpd-2.0.64]
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-mods-shared=most

[참고사항] configure를 하면 어떤 설정을 하는지 알고 싶다면 config.log 파일을 얼여 보시면 되고 실제 Makefile파일에 정의를 합니다.
[2010-11-18 15:17:42]-[root@server102:/usr/local/src/httpd-2.0.64]
# ls -lt
합계 1504
-rw-r--r--   1 root root     48627 11월 18 15:12 config.log
drwxr-xr-x   5  500 pegasus   4096 11월 18 15:12 build
drwxr-xr-x   2  500 pegasus   4096 11월 18 15:12 include
drwxr-xr-x   4  500 pegasus   4096 11월 18 15:12 support
-rw-r--r--   1 root root      8570 11월 18 15:12 Makefile
-rwxr-xr-x   1 root root     37343 11월 18 15:12 config.status
-rw-r--r--   1 root root       960 11월 18 15:12 modules.c
-rwxr-xr-x   1 root root       143 11월 18 15:11 config.nice

[설명] make(source 컴파일 과정) make install(컴파일이 완료한 것을 실행시켜서 설치)
[2010-11-18 15:15:56]-[root@server102:/usr/local/src/httpd-2.0.64]
# make; make install;



4. PHP 5.3  설치 가이드

[설명] 압축 해제
[2010-11-18 16:38:13]-[root@server102:/usr/local/src]
# tar zxf php-5.3.3.tar.gz
[2010-11-18 16:39:20]-[root@server102:/usr/local/src]
# cd php-5.3.3

[설명] configure 환경설정
[2010-11-22 14:10:25]-[root@server102:/usr/local/src/php-5.3.3]
# ./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(source 컴파일 과정) make install(컴파일이 완료한 것을 실행시켜서 설치)
[2010-11-22 14:16:18]-[root@server102:/usr/local/src/php-5.3.3]
# make; make install;

[2010-11-18 15:34:21]-[root@server102:/usr/local/apache/conf]
# vi httpd.conf
[설명] 아파치 웹서버의 포트를 설정 합니다. ServerName에 www.estenpark.com:80으로 설정 해도 됩니다.
Listen 80
[설명] 서버의 도메인 이름을 적습니다. 만약 도메인이 없을 경우 IP를 입력 해도 됩니다.(/etc/hosts)
ServerName www.estenpark.com
[설명] URL상의 서버 root문서가 위치하는 디렉토리를 적습니다.
DocumentRoot "/usr/local/apache/htdocs"
[설명] 디렉토리의 인덱스파일(처음열리는 파일)로 사용할 파일이름을 적습니다.
DirectoryIndex index.html index.html.var
[설명] 이부분은 아래 내용에 추가하시면 됩니다. PHP 환경설정 하는 부분입니다.
AddType application/x-httpd-php .php .htm .html .inc .php5 .php4
AddType application/x-httpd-php-source .phps

[설명] DSO support항목에서 아래 모듈부분이 활성화되었는지 확인 합니다. 없을 경우 PHP만 재설치해야 합니다.
LoadModule php5_module        modules/libphp5.so

[설명] php.ini 환경설정 파일을 복사합니다.
[2010-11-22 14:22:55]-[root@server102:/usr/local/src/php-5.3.3]
# cp php.ini-production /usr/local/apache/conf/php.ini



5. Zend Optimizer 설치 가이드

[설명] 압축 해제
[2010-11-18 16:38:13]-[root@server102:/usr/local/src]
# tar zxf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
[2010-11-26 15:16:07]-[root@server102:/usr/local/src]
# cd ZendOptimizer-3.3.9-linux-glibc23-i386

[설명] 설치를 시작 합니다. 3.3버전 이후 부터는 설치하는 방법이 조금 까다로워 졌습니다.
[설명] PHP버전을 확인합니다.
[2010-11-26 15:23:10]-[root@server102:/usr/local/src/ZendOptimizer-3.3.9-linux-glibc23-i386/data]
# php -v
PHP 5.3.3 (cli) (built: Nov 22 2010 14:21:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

[설명] ZendOptimizer 최신버전에는 PHP5.3 버전이 없습니다. 그래서 5.2 버전을 설치 하도록 하겠습니다.
[2010-11-26 15:23:28]-[root@server102:/usr/local/src/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp]
# ls
ZendOptimizer.so
[2010-11-26 15:23:29]-[root@server102:/usr/local/src/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp]
# cp ZendOptimizer.so /usr/local/apache/lib
[2010-11-26 15:41:36]-[root@server102:/usr/local/apache/bin]
# find /usr -name 'php.ini' -type f
/usr/local/apache/conf/php.ini
[2010-11-26 15:41:36]-[root@server102:/usr/local/apache/bin]
[설명] ZendOptimizer를 추가하기 위해서 아래와 같이 내용을 추가 합니다.(마지막 라인에 넣어도 됩니다.)
# vi /usr/local/apache/conf/php.ini

[Zend]
zend_optimizer.version=3.3.9
zend_extension=/usr/local/apache/lib/ZendOptimizer.so


[설명] ZendOptimizer 설정 전.....
[2010-11-26 15:29:43]-[root@server102:/usr/local/include/php]
# php -v
PHP 5.3.3 (cli) (built: Nov 22 2010 14:21:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

[설명] ZendOptimizer 설정 후
# 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.3 (cli) (built: Nov 22 2010 14:21:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies





6. APM + Zend Optimizer 연동 확인
[설명] Apache 재가동 및 프로세스 확인
[2010-11-26 16:20:32]-[root@server102:/usr/local/apache/bin]
# ./apachectl restart
[2010-11-26 16:20:49]-[root@server102:/usr/local/apache/bin]
# ps -ef |grep -v grep |grep apache
root      5378     1  0 15:41 ?             00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7097  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7098  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7099  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7100  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7101  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start

[설명] DNS 세팅 후 연결 테스트 확인
[2010-11-26 16:16:33]-[root@server102:~]
# cat /etc/resolv.conf
nameserver 172.16.4.XXX
#nameserver 168.126.63.1
[2010-11-26 16:23:47]-[root@server102:~]
# ps -ef |grep -v grep |grep named
root      6509     1  0 16:12 ?        00:00:00 ./named

[설명] WEB 문성 생성(/usr/local/apache/htdocs)
[2010-11-26 16:26:00]-[root@server102:/usr/local/apache/htdocs]
# cat test.php
<?php
        phpinfo();
?>

[설명] Web 브라우저를 이용하여 정상적으로 가동 되는지 확인 합니다.
DNS에 estenpark.pe.kr 존파일이 172.16.4.XXX로 되어있습니다. 그래서 아래와 같은 화면이 나올 수 있습니다.
예 )
http://localhost/test.php
http://172.16.4.XXX/test.php
http://www.estenpark.com/test.php


[설명] 만약 설정이 재대로 되지 않았다면 위와 같은 웹페이지가 생성되지 않을 것입니다. 아래와 같은 스크립트를 실행하여 체크해보시기 바랍니다.
apm_check.sh
[2010-11-26 16:48:41]-[root@server102:~/scripts]
# csh apm_check.sh

-------------------------------------------------------
1 Process check
root      5378     1  0 15:41 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7097  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7098  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7099  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7100  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7101  5378  0 16:20 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7305  5378  0 16:26 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7306  5378  0 16:26 ?        00:00:00 /usr/local/apache/bin/httpd -k start
nobody    7307  5378  0 16:26 ?        00:00:00 /usr/local/apache/bin/httpd -k start
root      6509     1  0 16:12 ?        00:00:00 ./named     // DNS 데몬입니다.
-------------------------------------------------------

-------------------------------------------------------
2 Apache config check
ServerRoot "/usr/local/apache"
..
..
생략
..
..
LoadModule php5_module        modules/libphp5.so          // 설정 부분이 없다면 PHP를 재설치 하시기 바랍니다.
ServerAdmin you@example.com
ServerName www.estenpark.com:80
ServerTokens Full
ServerSignature On
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .htm .html .inc .php5 .php4   //  이부분이 설정이 잘못 되있을 경우 문서를 다운받는 행위를 할 것입니다.
AddType application/x-httpd-php-source .phps                       // 재설정 후 아파치를 재가동 하시기 바랍니다.
-------------------------------------------------------

3 Apache Module Check
httpd.exp         mod_auth_dbm.so     mod_expires.so     mod_negotiation.so
libphp5.so        mod_auth_digest.so  mod_ext_filter.so  mod_rewrite.so
mod_access.so     mod_autoindex.so    mod_headers.so     mod_setenvif.so
mod_actions.so    mod_cgi.so          mod_imap.so        mod_speling.so
mod_alias.so      mod_dav.so          mod_include.so     mod_status.so
mod_asis.so       mod_dav_fs.so       mod_info.so        mod_userdir.so
mod_auth.so       mod_dir.so          mod_log_config.so  mod_vhost_alias.so
mod_auth_anon.so  mod_env.so          mod_mime.so

// 동적 모듈파일이 존재하지 않는다면 아파치를 재설치해야 하고, PHP 설치후에는 libphp5.so가 존재하는지 확인해야 한다.
-------------------------------------------------------






7. apache 데몬 서비스에 등록

[설명] 리눅스에서 서비스를 등록 하고 자동으로 실행 시켜주면 리부팅 되도 계속 띄울 수 있습니다. 그래서 그러한 장점을 문서로 만들어 봤습니다. 아래 스크립트를 /etc/rc.d/init.d/ 만들어 주신 후에 chkconfig 명령어를 이용해서 서비스에 등록 하도록 하겠습니다.
[2010-11-26 18:09:10]-[root@server102:/usr/local/dns/sbin]
# cat /etc/rc.d/init.d/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
        . /etc/sysconfig/httpd
fi

# 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/apache2/bin/apachectl        // apache 설치한 디렉토리를 적습니다.
httpd=/usr/local/apache/bin/httpd
pid=$httpd/logs/httpd.pid
prog=httpd
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
        ;;
  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

[설명] 서비스를 등록 하면서 레벨과 부팅시 시작 할 수 있게 모두 활성화 시키겠습니다.
[2010-11-26 18:30:02]-[root@server102:/usr/local/dns/sbin]
# chkconfig --add httpd
[2010-11-26 18:30:38]-[root@server102:/usr/local/dns/sbin]
# chkconfig --level 2345 httpd on
[2010-11-26 18:30:55]-[root@server102:/usr/local/dns/sbin]
# chkconfig --list |grep httpd
httpd           0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제
[2010-11-26 18:30:55]-[root@server102:/usr/local/dns/sbin]
# setup





RHEL4 [ MySql5.1 + Apache(httpd.2.0.64) + php5.3  + zend optimizer 3.3.9] 설치 가이드를 완료 했습니다.



Comments