본문으로 바로가기

CentOS 5.3 - Apache, PHP, Mysql 설치

category 시스템/Linux 2009. 7. 2. 15:35
반응형


Apache, php, mysql 설치는 컴파일 설치로 진행한다.
본이의 사용 목적에 따라 폴더 변경 및 컴파일 옵션 변경 후 설치 하심 됨.

폴더 구조.
실제 apm 설치 폴더 : /usr/local/
소스 위치               ; /home/down/


1. SElinux 설정 및 Langauge 설정.

1-1. SElinux 사용안함 설정.
# vi /etc/selinux/config  ( shell 상태에서 setup 을 통해 설정 가능 )
- SELINUX=disable

1-2. 언어 설정.
# vi /etc/sysconfig/i18n
- LANG="koKR.UTF-8"
==> 수정.
- LANG="ko_KR.eucKR"
- SUPPORTED="ko_KR.eucKR:ko_KR.ko:ko_KR.UTF-8"

1-3. reboot


2. 업데이트 확인 및 Package 설치.

2-1. 업데이트 확인.
# yum check-update
# yum update

2-2. 필요 Package 확인 및 설치.
# rpm -qa gcc* cpp* compat-gcc*
# rpm -qa flex* libjpeg* libpng* freetype* gd*

확인 후 없는 패키지는 yum 을 통해 설치해 준다.

# yum -y install gcc cpp gcc-c++ compat-gcc-32-g77 flex
# yum -y install libjpeg-devel libpng-devel freetype-devel gd-devel
# yum -y install termcap libtermcap libtermcap-devel gdbm-devel
# yum -y install zlib* libxml* freetype* libpng* libjpeg*
# yum -y install compat-libstdc++ libstdc++-devel libstdc++

또는 업데이트로 일괄 처리.

# yum update gcc cpp gcc-c++ compat-gcc-32-g77 flex
# yum update libjpeg-devel libpng-devel freetype-devel gd-devel
# yum update termcap libtermcap libtermcap-devel gdbm-devel
# yum update zlib* libxml* freetype* libpng* libjpeg*
# yum update compat-libstdc++ libstdc++-devel libstdc++

5.3 에서는 compat-gcc-32-g77, compat-libstdc++  package 없음.


3. 시스템 상태 체크 및 최신 library 설치.

3-1. 커널 버젼 및 리눅스 버젼 확인.
# uname -a
Linux dev.xxx.xxx
kernel version : 2.6.18-128.1.14.el5

3-2. library 버젼 check  및 설치된 버젼 확인.
- gcc-4.1.2-44.el5
- cpp-4.1.2-44.el5
- flex-2.5.4a-41.fc6
- gcc-c++-4.1.2-44.el5
- libpng-1.2.10-7.1.el5_3.2
- libpng-devel-1.2.10-7.1.el5_3.2
- libjpeg-6b-37
- libjpeg-devel-6b-37
- freetype-2.2.1-21.el5_3
- freetype-devel-2.2.1-21.el5_3
- gd-2.0.33-9.4.el5_1.1
- gd-devel-2.0.33-9.4.el5_1.1

3-3. 최신 library 다운로드 및 컴파일 설치 하기.

- libpng 설치
# libpng : http://www.libpng.org
# wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.37.tar.gz?download

# ./configure && make && make install

- libjpeg 설치.  (설치 안해도 됨)
# jpeg : http://www.ijg.org
# wget http://www.ijg.org/files/jpegsrc.v7.tar.gz

# mkdir -p /usr/local/man/man1
# ./configure --enable-shared --enable-static
# make && make install

- freetype 설치
# freetype : http://www.freetype.org
# wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.9.tar.gz

# ./configure && make && make install

- gd 설치
# gd : http://www.libgd.org
# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz

# ./configure && make && make install



4. Apache, PHP, MySQL 인스톨 하기.

4-1. 버젼 다운로드.
- apache 2.2.11 : http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.2.11.tar.gz
- php 5.2.10  : http://kr.php.net/get/php-5.2.10.tar.gz/from/this/mirror
- MySQL 5.1 : http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.36.tar.gz/from/ftp://mirror.khlug.org/mysql/

- 다운로드.
# cd /home/down/apm
# wget http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.2.11.tar.gz
# wget http://kr.php.net/get/php-5.2.10.tar.gz/from/this/mirror
# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.36.tar.gz/from/ftp://mirror.khlug.org/mysql/

- 압축 해제
# tar -zxvf httpd-2.2.11.tar.gz
# tar -zxvf php-5.2.10.tar.gz
# tar -zxvf mysql-5.1.36.tar.gz


4-2. MySQL 설치.
- version : mysql 5.1.36
- location : /usr/local/mysql

- user 등록
# useradd -M -s /bin/false mysql

# cd /home/down/apm/mysql-5.1.36
# ./configure --prefix=/usr/local/mysql \
    --with-charset=utf --with-extra-charsets=all \
    --enable-thread-safe-client --with-readline

** mysqli 옵션 이용시 --enable-thread-safe-client 추가. (httpd를 쓰레드로 운영(--with-mpm=worker) 할때)
** ssh 접속시 (putty,utf-8) 콜솔에서 한글입력이 가능 옵션 : --with-readline

# make
# make install

- 환경파일 복사 및 초기화 / 실행.
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root .
# chown -R mysql var
# chgrp -R mysql .

# pwd
/home/down/apm/mysql-5.0.67
# cp support-files/my-huge.cnf /etc/my.cnf  (? 이거때문에 문제 생기는 경우 있음)

# vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
# source ~/.bash_profile

또는 mysql 실행 파일을 /bin/ 밑으로 복사

- 자동 실행 설정.
# cp share/mysql/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list | grep mysqld

- 레벨 수정. (안해도됨)
# chkconfig --level 24 mysqld off
# chkconfig --list mysqld
mysqld          0:해제  1:해제  2:해제  3:활성  4:해제  5:활성  6:해제

- 실행 및 root 암호 설정.
# /etc/init.d/mysqld start
# mysqladmin -u root password 암호
or
mysql> update user set password=password('newpwd') where user='root';
or
mysql> set password for 'root'@'localhost'=password('newpwd');


### unix 설치 시 참조.
# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# gunzip < /home/down/apm/mysql-5.1.34.tar.gz | tar xvf -
# ln -s /usr/local/mysql-5.1.34 mysql
# cd mysql
# chown -R mysql .
# chgrop -R mysql .
# scripts/mysql install_db --user=mysql
# chown -R root .
# chown -R mysql data
# bin/mysqld_safe --user=mysql &


4-3. Apache 설치.
- version : httpd 2.2.11
- location : /usr/local/apache
** 2.2 대 버젼은 기본적으로 htdocs 폴더 접근이 제한되 있음. 가상유저 또는 virtual host 설정 후 테스트 해보기.

- configuration
- 일반적 config
# ./configure \
# --prefix=/usr/local/apache \
# --enable-so \
# --enable-mods-shared=all \
# --enable-rewrite

- ssl 포함해 컴파일 할때 openssl install 후 컴파일 하기.
# yum install openssl*
# ./configure \
# --prefix=/usr/local/apache \
# --enable-so \
# --enable-mods-shared=all \
# --enable-ssl \
# --with-ssl \
# --enable-rewrite

# make && make install

- 자동실행 설정.
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# chmod 755 /etc/init.d/httpd
# vi /etc/init.d/httpd  내용 추가.
---------------------------------------------------------------------------
#!/bin/sh
#
# Apache control script for the Apache HTTP Server
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server
---------------------------------------------------------------------------

위 설정 안될시.

# vi /etc/rc.local
----------------------------------------------------
/usr/local/apache/bin/apachectl -k start  라인 추가
----------------------------------------------------

- conf 수정. (서비스 용도 맞게 조절)

- Firewall 설정 서비스 port 오픈.
# vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# /etc/init.d/iptables restart


4-4. PHP 설치.
- version : php 5.2.10
- location : /usr/local/php

- 컴파일시 에러나는 항목은 yum 을 통해 설치 후 진행할것.
# yum install libxml2 bzip* curl-devel ncurses-devel
# yum install licjpeg-devel libpng-devel libxml-devel freetype-devel gd-devel
# yum install libc-client libc-client-devel net-snmp-devel libmcrypt libmcrypt-devel

- config
# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/apache/conf \
--enable-magic-quotes \
--with-curl \
--with-xpm-dir=/usr \
--with-mcrypt \
--with-zlib \
--with-gd \
--with-ttf \
--with-gmp \
--with-xml \
--disable-rpath \
--with-iconv \
--enable-safe-mode \
--enable-bcmath \
--enable-gd-native-ttf \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-inline-optimization \
--enable-mbstring \
--enable-mbregex \
--enable-ftp \
--with-jpeg-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-exif \
--enable-calendar \
--enable-mod-charset \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-ncurses \
--with-bz2 \

# make && make install

- 환경파일 복사.
# cp php.ini-dist /usr/local/apache/conf/php.ini

- apache conf 수정.
# vi /usr/local/apache/conf/httpd.conf
-------------------------------------------------------------------
<ifModule dir_module>
 DirectoryIndex index.php index.html
</ifModule>

<ifModule mime_module>
.....
 #AddType text/html .shtml
 #AddOutputFilter INCLUDES .shtml

 AddHandler php5-script .phtml .php .inc .ini .html
 AddType application/x-httpd-php-source .phps .incs .inis
</ifMoudle>
-------------------------------------------------------------------

- apache 재시작

- phpinfo 로 확인.


















반응형