CentOS 리눅스 웹서버 구축관리
##############################################################################
CentOS 5.3
apache -> httpd-2.2.14.tar.gz
php -> php-5.2.12.tar.gz
mysql -> mysql-5.1.41.tar.gz
phpmyadmin -> phpMyAdmin-3.2.4-all-languages.tar.gz
ZendOptimizer -> ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mod_evasive -> http://www.zdziarski.com/projects/mod_evasive/
##############################################################################설치 웹서버(apm) => apache, php, mysql
설치 방법 => 소스 파일 다운로드후 컴파일을 통해 설치
##############################################################################
- yum은 Yellowdog Updater, Modified의 약자로 rpm기반의 시스템을 위한 자동 업데이터이자
패키지 설치/삭제도구입니다. Yum은 자동적으로 의존성을 처리해주며 rpm 패키지들을 안전하게
설치, 삭제 및 업데이트하기 위해 반드시 해야할 일들을 스스로 해결합니다.
##############################################################################
1) 기존 apm 삭제
- 기존 설치된 것 확인
=> rpm -qa httpd php mysql
- 설치된 것이 있으면 yum 으로 삭제
=> yum remove httpd php mysql
- 삭제 확인
=> rpm -qa httpd php mysql
2) APM 다운로드(저장 디렉토리 /usr/local/src/apm/)
- apache 다운로드 : http://www.apache.org/
=> wget http://mirror.khlug.org/apache/httpd/httpd-2.2.14.tar.gz
- php 다운로드 : http://www.php.net/
=> wget http://kr.php.net/get/php-5.3.1.tar.gz/from/this/mirror
- mysql 다운로드 : http://www.mysql.org/
=> wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz/from/http://mirror.khlug.org/mysql/
3) 컴파일러 점검
- 소스코드 컴파일을 위한 컴파일러 설치 유무확인
=> rpm -qa gcc* cpp* compat-gcc* flex*
- gcc* cpp* compat-gcc* flex* 중에서 미설치된 컴파일러는 yum 을 통해서 설치
=> yum -y install gcc cpp gcc-c++ compat-gcc-32-g77 flex
4) 라이브러리 점검
- 반드시 필요한 라이브러리
=> libpng, freetype, libjpeg, gd
- 라이브러리 설치 유무확인
=> rpm -qa libjpeg* libpng* freetype* gd-*
- 라이브러리 미설치시 yum 을 통해서 설치(rpm방식)
=> yum install libjpeg-devel libpng-devel freetype-devel gd-devel
- 소스 다운로드 방식의 설치(최신 라이브러리 다운로드)
- libjpeg => http://www.ijg.org/
=> wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
=> tar zxvf jpegsrc.v7.tar.gz
=> cd jpeg-7
=> mkdir -p /usr/local/man/man1
=> ./configure --enable-shared --enable-static
=> make && make install
- libpng => http://www.libpng.org/
=> wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.41.tar.gz?download
=> tar zxvf libpng-1.2.41.tar.gz
=> cd libpng-1.2.41
=> ./configure
=> make && make install
- freetype => http://www.freetype.org/
=> wget http://sourceforge.net/projects/freetype/files/freetype2/2.3.11/freetype-2.3.11.tar.gz/download
=> tar zxvf freetype-2.3.11.tar.gz
=> cd freetype-2.3.11
=> ./configure
=> make && make install
- gd => http://www.libgd.org/
=> wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
=> tar zxvf gd-2.0.35.tar.gz
=> cd gd-2.0.35
=> ./configure
=> make && make install
5) MySQL 설치
- 다운로드한 파일 압축 해제
==> tar -zvxf mysql-5.1.41.tar.gz
==> cd mysql-5.1.41
- mysql 계정 생성
==> useradd -M -s /bin/false mysql
- ./configure 실행
==> ./configure \
==> >--prefix=/usr/local/server/mysql \
==> >--with-charset=utf8 \
==> >--with-extra-charsets=all
- make && make install(설치경로 -> /usr/local/server/mysql)
==> make && make install
- 환경설정파일 복사(support-files/ -> /etc/my.cnf)
==> cp /usr/local/src/apm/mysql-5.1.41/support-files/my-large.cnf /etc/my.cnf
- 기본 DB 생성
==> cd /usr/local/server/mysql
==> bin/mysql_install_db --user=mysql
- 디렉토리 권한 설정
==> chown -R root .
==> chown -R mysql var
==> chgrp -R mysql .
- 환경변수 등록(경로 추가)
==> vi /root/.bash_profile
==> PATH=$PATH:$HOME/bin:/usr/local/server/mysql/bin <- 수정
==> source ~./bash_profile
- 자동실행 설정
==> cp share/mysql/mysql.server /etc/init.d/mysqld
==> chkconfig --add mysqld
==> chkconfig --list|grep mysqld
- root 함호 등록 및 테스트
==> /etc/init.d/mysql start
Start MySQL [ OK ]
==> mysqladmin -u root password ws960501
==> mysql -u root -p
6) Apache 설치
- 기본경로1 : /usr/local/src/apm
- 다운로드한 파일 압축 해제
==> tar -zxf httpd-2.2.14.tar.gz
==> cd httpd-2.2.14
- 기본경로2 : /usr/local/src/apm/httpd-2.2.14
- ./configure 실행
==> ./configure \
==> >--prefix=/usr/local/server/apache \
==> >--enable-mods-shared=all \
==> >--enable-so \
==> >--enable-rewrite
- make && make install (설치)
- 기본경로3 : /usr/local/server/apache/
- 자동실행 설정
==> cp bin/apachectl /etc/init.d/httpd
==> vi /etc/init.d/httpd <- 아래내용을 2번째 줄부터 추가
# 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
- 환경설정
==> conf/httpd.conf 편집
==> vi conf/httpd.conf
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody <- daemon=>nobody
Group nobody <- daemon=>nobody
</IfModule>
</IfModule>
- 테스트
==> /etc/init.d/httpd start
==> http://192.168.2.236 으로 접속
7) php 설치
- 기본경로1 : /usr/local/src/apm/
- 다운로드한 파일 압축 해제
####################################
=> tar -zxf php-5.3.1.tar.gz
=> cd php-5.3.1
####################################
- 기본경로2 : /usr/local/src/apm/php-5.3.1
- ./configure 실행
####################################
./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
####################################
- make && make install 실행
####################################
=> make && make install
####################################
- 환경설정
####################################
=> 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.htm index.php
</IfModule>
# AddType 지시어 추가
<IfModule mime_module>
AddType application/x-httpd-php.php
AddType application/x-httpd-php-source.phps
</IfModule>
####################################
- 테스트
####################################
=> /etc/init.d/httpd restart
==> vi /usr/local/server/apache/htdocs/phpinfo.php
<? phpinfo(); ?>
=> http://192.168.2.236/phpinfo.php
####################################
8) 환경설정 => apache
9) 환경설정 => php
10) 환경설정 => MySQL
11) ZendOptimizer 설치
12) DOS 설정
13) Webalizer 설치(통계분석)
14) APM 테스트
15) 제로보드 설치
16) 테테툴즈 설치