본문 바로가기

Linux/Centos

LAMP 설치 (CentOS 5.4)

Linux (리눅스 운영체제);

Apache (아파치 웹 서버);

MySQL 데이터베이스 관리 시스템(데이터베이스 서버);

PHP;

Zend Optimizer + eAccelerator;

제 설치 기록입니다. 한번이라도 설치해 보신 분들 & configure 옵션에 대해 이해 가능하신 분들을
위한 빠른 가이드 입니다.


소스 컴파일을 위한 패키지를 먼저 설치합니다.

# yum -y install gcc gcc-c++ compat-gcc-34-g77 automake autoconf libtool flex

관련 라이브러리를 설치 합니다.

# yum -y install zlib-devel libpng-devel freetype-devel libjpeg-devel libxml2-devel gd-devel libXpm-devel


라이브러리도 소스 컴파일 하셔도 됩니다.



MySQL

# yum -y install ncurses-devel zlib-devel
# useradd -M -s /bin/false mysql
# cd /usr/local/src
# wget ftp://mirror.khlug.org/mysql/Downloads/MySQL-5.1/mysql-5.1.42.tar.gz
# tar xvfz mysql-5.1.42.tar.gz
# cd mysql-5.1.42
# ./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/var \
--enable-shared --enable-assembler \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-mysqld-user="mysql" \
--with-readline --without-debug \
--without-docs \
--with-charset=utf8 \
--with-extra-charsets=all
# make && make install
# /usr/local/mysql/bin/mysql_install_db --user=mysql
# chown -R root.mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/var
# vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
# vi /etc/skel/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
# source ~/.bash_profile
# cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list | grep mysqld
# /etc/init.d/mysqld start
# mysqladmin -u root password ****


Apache

# cd /usr/local/src
# wget http://mirror.apache-kr.org/httpd/httpd-2.2.14.tar.gz
# tar xvfz httpd-2.2.14.tar.gz
# cd httpd-2.2.14

# vi server/mpm/prefork/prefork.c
#define DEFAULT_SERVER_LIMIT 1024
#define MAX_SERVER_LIMIT 200000

# vi server/mpm/worker/worker.c
#define DEFAULT_SERVER_LIMIT 16
#define MAX_SERVER_LIMIT 20000
#define DEFAULT_THREAD_LIMIT 64

# ./configure --prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-headers \
--with-mpm=prefork

# make && make install

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

# vi /etc/init.d/httpd
# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /usr/local/apache/bin/apachectl
# config: /usr/local/apache/conf/httpd.conf
# pidfile: /usr/local/apache/logs/httpd.pid

# chkconfig --add httpd
# chkconfig --list | grep httpd

# vi /usr/local/apache/conf/httpd.conf
DirectoryIndex index.html index.htm index.php index.php3

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

User nobody
Group nobody

# /etc/init.d/httpd start


PHP

# cd /usr/local/src
# wget http://kr2.php.net/get/php-5.2.12.tar.bz2/from/this/mirror
# tar xvfj php-5.2.12.tar.bz2
# cd php-5.2.12
# ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/apache/conf \
--with-mysql=/usr/local/mysql \
--enable-safe-mode \
--enable-sockets \
--enable-sigchild \
--enable-magic-quotes \
--with-libxml-dir \
--with-zlib \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-ttf \
--with-freetype-dir \
--with-xpm-dir \
--enable-gd-native-ttf \
--with-gettext \
--enable-sysvsem \
--enable-sysvshm \
--enable-mbstring

# make && make install
# cp php.ini-dist /usr/local/apache/conf/php.ini

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

# /etc/init.d/httpd restart

# cat <<EOF >> /usr/local/apache/htdocs/phpinfo.php
> <? phpinfo(); ?>
> EOF


Zend Optimizer

# mkdir /usr/local/Zend

32bit
# cd /usr/local/src
# wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
# tar xvfz ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
# cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/Zend/

64bit
# cd /usr/local/src
# wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
# tar xvfz ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
# cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/Zend/

eAccelerator

# mkdir /var/cache/eaccelerator
# chown nobody:nobody /var/cache/eaccelerator
# chmod 644 /var/cache/eaccelerator

# cd /usr/local/src
# wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
# tar xvfj eaccelerator-0.9.5.3.tar.bz2
# cd eaccelerator-0.9.5.3
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
# make && make install
# vi /usr/local/apache/conf/php.ini

[Zend]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
zend_optimizer.version=3.3.9
zend_extension=/usr/local/Zend/ZendOptimizer.so

# /etc/init.d/httpd restart