티스토리 뷰

728x90
반응형

[기본 yum 설치]
1. ]#yum install -y gcc*
2. ]#yum install -y ncurses-devel


1. 설치파일 준비

   apache : http://httpd.apache.org/download.cgi

   php : http://www.php.net/downloads.php

   mysql : http://dev.mysql.com/downloads

 

MY-SQL Setup

1. my-sql  유저 생성

             ]# useradd -Ms /bin/false mysql

             ]# cat /etc/passwd

             mysql:x:501:501::/home/mysql:/bin/false

             TIP] 사용권이 없으면서 유저 기본 디렉토리를 만들지 않는다.

 

2. 파일 다운로드

             ]# wget http://dev.mysql.com/get/Downloads/MySQL-6.0/mysql-                                                     6.0.6-alpha.tar.gz/from/ftp://mysql.byungsoo.net/pub/mysql/

             TIP] 해당 파일이 없을 경우 http://mysql.com(공식 홈페이지)에서 소스파일을 다운로드

 

3. 압축 해제 컴파일 옵션 설정

             ]# tar xvfz mysql-6.0.6-alpha.tar.gz

             ]# ./configure \

             --prefix=/usr/local/server/mysql \

             --with-charset=utf8 \

             --with-extra-charsets=all

             TIP]

             많은 컴파일 옵션들을 보려면 ./configure --help 입력한다.

 

4. 설치

             ]# make && make install

             TIP] & : 백그라운드로 실행

                    && : make 하고 나서 이어서 make install 하겠다는   

5. 설치 확인 환경 설정

             ]# ls -al /usr/local/server/mysql

             합계 88

             drwxr-xr-x 11 root root 4096 10  7 12:14 .

             drwxr-xr-x  3 root root 4096 10  7 12:06 ..

             drwxr-xr-x  2 root root 4096 10  7 12:07 bin

             drwxr-xr-x  2 root root 4096 10  7 12:06 docs

             drwxr-xr-x  3 root root 4096 10  7 12:06 include

             drwxr-xr-x  3 root root 4096 10  7 12:06 lib

             drwxr-xr-x  2 root root 4096 10  7 12:06 libexec

             drwxr-xr-x  4 root root 4096 10  7 12:07 man

             drwxr-xr-x 10 root root 4096 10  7 12:14 mysql-test

             drwxr-xr-x  4 root root 4096 10  7 12:14 share

             drwxr-xr-x  5 root root 4096 10  7 12:14 sql-bench

            

             ]# pwd

             /usr/src/mysql-6.0.6-alpha/support-files

            

             ]# cp my-large.cnf /etc/my.cnf

             TIP]

                           my-huge.cnf : 메모리가 1G-2G 사이일 사용한다.

                           my-large.cnf : 메모리가 512M 사용한다.(이것을 사용 권장)

                           my-medium.cnf : 메모리가 64-256M 사이일 사용한다.

                           my-small.cnf : 메모리가 64M 보다 작을 사용한다.

            

             ]# ls -al /etc/my.cnf

             -rw-r--r-- 1 root root 4880 10  7 12:36 /etc/my.cnf

 

6. DB 생성 권한 설정

             ]# cd /usr/local/server/mysql/bin

             ]# ./mysql_install_db --user=mysql

            

             ]# cd /usr/local/server/mysql

             ]# chown -R root .

             ]# chown -R mysql var

             ]# chgrp -R mysql .

 

7. 환경 변수 등록

             ]# cd /root

            

             ]# vi ~/.bash_profile

                           # .bash_profile

                           # Get the aliases and functions

                           if [ -f ~/.bashrc ]; then

                                   . ~/.bashrc

                           fi

                           # User specific environment and startup programs

                           PATH=$PATH:$HOME/bin:/usr/local/server/mysql/bin

                           export PATH

                           unset USERNAME

            

             ]# source ~/.bash_profile

                           TIP]

                           변경한 환경 변수는 다시 로그인 때에 적용되지만 source 명령어를 이용하면

                           즉시 적용할 수도 있다.

 

8. 자동 실행 설정 실행

             ]# cd /usr/local/server/mysql/

             ]# cp share/mysql/mysql.server /etc/init.d/mysqld

             ]# chkconfig --add mysqld

            

             ]# chkconfig --list | grep mysqld

                           mysqld          0:해제  1:해제  2:활성  3:활성  4:활성  5:해제  6:해제

                           런레벨 2,3,4,5 모드에서만 실행하게 설정

             ]# /etc/init.d/mysqld start

 

9. root 패스워드 설정 로그인 확인

             ]# cd /usr/local/server/mysql/bin

             ]# mysqladmin -u root password develop

            

             ]# mysql -u root –p

            

10.  데몬 확인

             ]# ps -ef | grep mysqld

 

Apache Setup

1. 파일 다운로드

             ]# wget http://mirror.apache-kr.org/httpd/httpd-2.2.9.tar.gz

 

2. 압축 해제 옵션 설정

             ]# tar fxpz httpd-2.2.9.tar.gz

             ]# cd httpd-2.2.9

             ]# ./configure \

             --prefix=/usr/local/server/apache \

             --enable-mods-shared=all \

             --enable-so \

             --enable-rewrite

            

             TIP]

             --prefix=/usr/local/server/apache \      <<== 실처 디렉토리를 지정한다.

             --enable-mods-shared=all \        <<== 모든 모듈을 DSO 모드로 작성한다.

             --enable-so \                   <<== DSO 모드를 활성화 한다.

             --enable-rewrite             <<== URL 재작성 모듈을 활성화 한다.

            

             DSO(Dynamic Shared Object)?

             아파치의 설치 방식은 가지가 있다. 하나는 DSO 동적 모듈 적재 방식이고,

             하나는 Static Object라고 하는 방식이다.

            

             DSO 방식은 아파치를 먼저 컴파일하고 다른 모듈들을 추가로 설치할 아파치를

             다시 컴파일하지 않고 모듈을 추가할 있다.

            

             Static 방식은 모듈을 추가하려면 아파치를 실핼될 때에 모든 모듈을 로드하므로

             시스템의 자원을 많이 소모한다.

 

             하지만 DSO 방식은 사용자의 요청이 있을 때에 모듈을 로드하므로 Static 방식보다는

             느리지만, 시스템의 자원을 적게 소모한다.

            

             최근에는 하드웨어의 발전으로 수행 속도가 크게 차이 나지 않는다.

             그래서 대부분 여러가지 장점이 있는 DSO 방식으로 설치한다.

 

 

 

3. 설치

             ]# make && make install

 

4. 자동 실행 설정

             ]# cp /usr/local/server/apache/bin/apachectl /etc/init.d/httpd

             ]# cd /etc/init.d

            

             ]# vi httpd

                           # When multiple arguments are given, only the error from the _last_

                           # one is reported.  Run "apachectl help" for usage info

                           #

                           ARGV="$@"

                           #

                           #

                           # chkconfig: 2345 90 90 추가(앞에 # 붙여준다!)

                           # description: init file for Apache server daemon  추가(앞에 # 붙여준다!)

                           # processname: /usr/local/server/apache/bin/apachectl 추가(앞에 # 붙여준다!)

                           # config: /usr/local/server/apache/conf/httpd.conf 추가(앞에 # 붙여준다!)

                           # pidfile: /usr/local/server/apache/logs/httpd.pid 추가(앞에 # 붙여준다!)

                           #

                           #

             ]# chkconfig --add httpd

             ]# chkconfig --list | grep httpd

                           Httpd 0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제

 

5. 환결 설정

             ]# cd /usr/local/server/apache/conf/

             ]# vi httpd.conf

                           User daemon -> daemon nobody 변경!

                           Group daemon -> daemon nobody 변경!

                           root 권한으로 실행된 아파치의 하위 프로세스를 이곳에서 지정한 사용자로

                           실행한다는 의미이다.

                          

                           ServerName 192.168.0.52:80 (주석 해제)

                           도메인이 있다면 도메인을 적어주고 없다면 서버의 IP 적어준다.

                           만약 항목을 설정하지 않으면 127.0.0.1으로만 접속이 된다

 

6. 아파치 실행 데몬 확인

             ]# cd /etc/init.d

             ]# ./httpd start

            

             ]# ps -ef | grep httpd

             root      9307     1  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             nobody    9308  9307  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             nobody    9309  9307  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             nobody    9310  9307  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             nobody    9311  9307  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             nobody    9312  9307  0 08:10 ?        00:00:00 /usr/local/server/apache/bin/httpd -k start

             root      9315 27038  0 08:11 pts/1    00:00:00 grep httpd

 

             인터넷 익스플로로 주소차에 http://IP or 도메인(http://192.168.247.132) 입력!

             It works! 나오면 완성!

 

7. Virtual hosts 사용시 설정

             ]# vi /usr/local/server/apache/conf/httpd.conf

                          # Virtual hosts

                          #Include conf/extra/httpd-vhosts.conf (주석제거)

            

             ]# cd /usr/local/server/apache/conf/extra

             ]# vi httpd-vhosts.conf

                           <VirtualHost *:80>

                                        ServerAdmin webmaster@dummy-host2.example.com

                                      DocumentRoot "/home/root/public_html"

                                      ServerName 192.168.0.52

                                        ErrorLog "logs/dummy-host2.example.com-error_log"

                                        CustomLog "logs/dummy-host2.example.com-access_log" common

                           </VirtualHost>

PHP Setup

1. 파일 다운로드

                           ]#wget http://www.php.net/get/php-5.2.6.tar.gz/from/jp2.php.net/mirror

            

             2. 압축 해제

                           ]# tar fxz php-5.2.6.tar.gz

             3. 필수 패키지 설치

                           ]# yum install libxml2 libxml2-devel

                           ]# yum install libjpeg  libjpeg-devel

                           ]# yum install libpng  libpng-devel

                           ]# yum install freetype freetype-devel freetype-utils

                           ]# yum install zlib zlib-devel

                           ]# yum install gd gd-devel

 

             4. 컴파일 옵션 설정

                           ]#./configure --prefix=/usr/local/server/php --with-apxs2=/usr/local/server/apache/bin/apxs --with-mysql=/usr/local/server/mysql --with-config-file-path=/usr/local/server/apache/conf --disable-debug --enable-safe-mode --enable-track-vars --enable-sockets --with-mod_charset --with-charset=utf8 --with-xml --with-language=korean --enable-mailparse --enable-calender --enable-sysvsem=yes --enable-sysvshm=yes --enable-ftp --enable-magic-quotes --enable-gd-native-ttf --enable-url-include --enable-trans-id --enable-inline-optimization --enable-bcmath --with-jpeg --with-png --with-zlib --with-jpeg-dir=/usr --with-png-dir=/usr/lib --with-freetype-dir=/usr --with-libxml-dir=/usr --enable-exif --with-gd --with-ttf --with-gettext --enable-sigchild --enable-mbstring

                          

                           TIP]

                                        --prefix=/usr/local/server/php

                                        php 설치될 곳을 지정한다.

                                        --with-apxs2=/usr/local/server/apache/bin/apxs

                                        아파치의 apxs 이용해 아파치에 모듈을 적재한다.

                                        --with-mysql=/usr/local/server/mysql

                                        MySQL 연동한다.

                                        --with-config-file-path=/usr/local/server/apache/conf

                                        php 환경설정 파일인 php.ini 생성될 위치를 지정한다.

                                       

                                        기타 옵션은 php사용시 필요한 라이브러리들을 포함하는 옵션이다.

             5. 설치

                           ]# make

                           ]# make install

 

             6. 모듈 확인

                           ]# find / -name libphp5.so

                                        /usr/local/apache/modules/libphp5.so

                                        /installfile/php-5.2.6/libs/libphp5.so

                                        /installfile/php-5.2.6/.libs/libphp5.so

 

             7. PHP 환경 설정

                           ] # cp php.ini-dist /usr/local/server/apache/conf/php.ini

                           ] # vi /usr/local/server/apache/conf/httpd.conf

                           <IfModule dir_module>

                                        DirectoryIndex index.html index.php 추가

                           </IfModule>

                           <IfModule mime_module>

                           #

                           # TypesConfig points to the file containing the list of mappings from

                         # filename extension to MIME-type.

                           #

                         TypesConfig conf/mime.types

                         #

                         # AddType allows you to add to or override the MIME configuration

                         # file specified in TypesConfig for specific file types.

                         #

                         #AddType application/x-gzip .tgz

                         #

                         AddType application/x-httpd-php .php

                         AddType application/x-httpd-php-source .phps

 

                           DocumentRoot "/usr/local/server/apache/htdocs"

 

                           #

                           # Each directory to which Apache has access can be configured with respect

                           # to which services and features are allowed and/or disabled in that

                           # directory (and its subdirectories).

                           #

                           # First, we configure the "default" to be a very restrictive set of

                           # features.

                           #

 

                           <Directory /home>

                               Options FollowSymLinks

                               AllowOverride None

                               Order allow,deny

                               Allow from all

                           </Directory>

 

             8. 설치 확인

                           ]# mkdir /home/root

                           ]# mkdir /home/root/public_html

             .            Virtual hosts -> DocumentRoot 설정한 위치에 디렉토리 생성

                          

                           ]# cd /home/root/public_html

                          ]# vi index.php

                                        <?phpinfo();?> 추가

                                        php정보를 출력하는 index.php 파일 생성

                          

                           ]# /etc/init.d/httpd restart

             Tip]

             httpd: Syntax error on line 104 of /usr/local/server/apache/conf/httpd.conf:

                  Cannot load /usr/local/server/apache/modules/libphp5.so

             into server: /usr/local/server/apache/modules/libphp5.so:

             cannot restore segment prot after reloc: Permission denied

            

             SELinux 보안 설정에 의한 에러

             해결방법]

                           ]# chcon -t texrel_shlib_t /usr/local/server/apache/modules/libphp5.so

                           ]# /etc/init.d/httpd restart

                           http://localhost ip or http://domain

                          

                           PHP 정보 출력시 설치 완료!!

728x90
반응형