OS/Linux

2011.12.07 리눅스 APM개념 및 APM설치

에몽이ㅋ 2012. 1. 9. 22:03

APM 이란?


Apache(웹서버)

PHP(웹프로그래밍 언어)

MySQL(데이터베이스)


를 합쳐서 APM이라고 한다. 이들 프로그램을 한 회사에서 만들 것이 아니며, 이 3가지 서로 잘 연동되어 운영되도록 만든 환경을 APM이라고 한다.


이제 설치 및 설정으로 가기로 하자


중구난방으로 설치하기 전에 간단한 순서부터 살펴보자

현재 설치는 소스컴파일을 기준으로 한다. rpm설치도 거의 비슷한 순서로 하면 될것이다.


소스다운로드    ----------->       Apache설치 및 설정      ------------------------>   MySQL 설치 및 설정     -------------

httpd-2.2.11                                  1.아파치 소스 컴파일                                               1.  MySQL 소스 컴파일

php-5.3.0                                     2.환경설정(/etc/ld.so.conf, /etc/init.d/httpd)             2.  환경설정(/etc/ld.so.conf)

mysql-5.5.18                                 3.시작프로그램에 등록                                             3.  초기화DB생성

      4.  사용자/그룹생성 및 DB소유권변경 

      5.  시작프로그램에 등록


-------> PHP설치 및 설정                   ----------->   설정테스트

1. PHP 소스 컴파일

2. PHP 모듈등록(httpd.conf)

3. 웹서버 재구동



소스다운로드는 google검색을 통해서 다운받자(여기서는 

Apache : httpd-2.2.11-8

MySQL : mysql-5.11.35-1.fc11

php : php-5.3.0 버젼)


1. Apache 설치 및 설정

1. 소스컴파일

다운 받은 소스 폴더에 들어가서


#  ./configure --prefix=/web/httpd2    --enable-module=so     --enable-mods-shared=most    --with-ssl

#  make

#  make install


2. 환경설정

/etc/ld.so.conf 파일을 열어서


/web/httpd2/lib

/web/httpd2/modules 을 추가해준다

추가 한 후 적용을 위해 ldconfig 실행

---------------------------

아파치 시작 스크립트 파일을 /etc/init.d에 복사한다.

#  cp  /web/httpd2/bin/apachectl          /etc/init.d/httpd2


/etc/init.d/httpd2 파일을 열어서 마지막에 두줄 추가

# chkconfig: - 85 15

# description: Apache Web server 2.2.11

(주석을 붙인채로 그대로 추가)

---------------------------

이후에 시작프로그램에 등록

chkconfig httpd2 on

service httpd2 start

----------------------------

이후 모질라 들어가서 http://localhost  접속     ----> It works! 나오면 성공!!


2. MySQL설치 및 설정

(설치하기 전!! 기존에 mysql이 있으면 필히 삭제한다. rpm -qa|grep mysql 찾아서 삭제.. 삭제안되면 --nodeps)

1. 소스 컴파일

#  ./configure   --prefix=/web/mysql     --localstatedir=/web/mysql/var     --with-charset=euckr

#  make && make install

2. 환경설정

1.  /etc/ld.so.conf 파일에 내용 추가

/web/mysql/lib/mysql     추가 후    ldconfig  로 내용 적용

2.  cp   /web/mysql/share/mysql/mysql.server     /etc/init.d/mysqld

3. 초기 DB생성

# /web/mysql/bin/mysql_install_db

# ls -l   /web/mysql/var          ---->  mysql, test   디렉토리가 보임을 확인

4. 사용자/그룹생성 및 DB소유권 변경

groupadd mysql

useradd -M    -d  /web/mysql  -g mysql  -s /bin/false   -r mysql

chown -R mysql.mysql   /web/mysql/var

5. 시작프로그램 등록

chkconfig mysqld on

service mysqld start

MySQL이 되는지 테스트

# PATH=$PATH:/web/mysql/bin  <----PATH에 MySQL 프로그램이 있는 디렉토리 등록

# mysql

mysql> show databases;

mysql> quit;

이후  /root/.bash_profile에 PATH부분에 mysql폴더/bin 추가하면 아무대서나 mysql실행가능

 

3. PHP설치 및 설정

1. PHP 소스 컴파일  #  ./configure --with-mysql=/web/mysql     --with-apxs2=/web/httpd2/bin/apxs  \

--with-mysqli=/web/mysql/bin/mysql_config     --with-imap-ssl      --disable-debug  \

--with-config-file-path=/etc \

--with-iconv   --with-gd    --with-jpeg-dir   --with-png-dir   --with-libxml-dir   --with-openssl \

--with-libdir=lib64(64bit 리눅스사용자를 위한 옵션)

( --with-mysql=/web/mysql   : MySQL이 설치된경로

  --with-apxs2=/web/httpd2/bin/apxs : Apache의 apxs디렉토리

  --with-mysqli=/web/mysql/bin/mysql_config  : MySQL 설정파일지정 

  --with-config-file-path=/etc  : php.ini파일을 어디에 두고 사용할지 지정, 디폴트는 /usr/local/lib)


※ 64bit 에서는 libmysqlclient.so파일 관련 configure에러가 날 수 있다.  이떄는 /mysql경로/lib 디렉토리를 cp로 /mysql경로/lib64/로 카피해주자.  (# cp  -r   /web/mysql/lib   /web/mysql/lib64)    잠재적인 문제는 아직 모르겠다. 이렇게하면 일단 설치는 가능


        # make && make install

이후   # ls  -l  /web/httpd2/modules/libphp5.so  파일이 생성되었는지 확인


2. PHP 모듈등록(/아파치설치경로/conf/httpd.conf)

98행쯤 LoadModule php5_module        modules/libphp5.so         <----- 없으면 추가
354행쯤 Addtype application/x-httpd-php  .php  .php3  .php4  .php5  .htm  .html  .inc      추가

PHP 설정파일 'php.ini-production'  을 /etc/php.ini로 복사한다.

3. 웹서버 재구동

service httpd2 stop

service httpd2 start

 

 

4. 설정테스트

 

# vi  /web/httpd2/htdocs/phpinfo.php 파일을 생성해서

<? phpinfo(); ?>

   를 입력한 후

 

http://서버IP/phpinfo.php 접속해서       php뭐시기 뭐시기, 표 나오면 성공!

 

혹시 안나오면  /etc/php.ini 에서

short_open_tag 검색해서 = Off  를   = On으로 변경하시고

service httpd2 stop

service httpd2 start  이후 다시 접속하시면 거의 될껍니다.


 

----------------------

이후 Zend 를 설치하시면 php 속도가 향상됩니다.

ZendOptimizer설치 : PHP 5.3이전

ZendGuard설치 : PHP 5.3이상버젼


------------------

apache 시작프로그램 등록쪽에서 오류가 날 수도 있습니다.(2번 설치해서 한번은 되고 한번은 안되고)

           --------> 해당 오류 구글검색