본문 바로가기

Linux/Apache,Tomcat

[linux]apache2+mysql 4 +php4

apm 설치순서

mysql 설치전 점검 : rpm -qa | grep mysql ->존재하면 지움


(1) zlib 설치
   zlib은 압축과 관련된 라이브러리 입니다.
[root@localhost local]# cd /usr/local/src
[root@localhost src]# wget http://ftp.superuser.co.kr/pub/etc/zlib-1.1.4.tar.gz
[root@localhost src]# tar xvfz zlib-1.1.4.tar.gz
[root@localhost src]# cd zlib-1.1.4
[root@localhost zlib-1.1.4]# ./configure && make && make install
[root@localhost zlib-1.1.4]# cd ..

(2) libpng 설치
  png 포맷을 다루기 위한 라이브러리입니다.
[root@localhost src]# wget http://ftp.superuser.co.kr/pub/etc/libpng-1.2.5.tar.gz
[root@localhost src]# tar xvfz libpng-1.2.5.tar.gz
[root@localhost src]# cd libpng-1.2.5
[root@localhost libpng-1.2.5]# cp scripts/makefile.linux makefile
[root@localhost libpng-1.2.5]# make test && make install
[root@localhost libpng-1.2.5]# cd ..

(3) freetype 2 설치
 글짜를 그릴 때 쓰는 라이브러리 입니다.
[root@localhost src]# wget http://ftp.superuser.co.kr/pub/etc/freetype-2.1.5.tar.gz
[root@localhost src]# tar xvfz freetype-2.1.5.tar.gz   
[root@localhost src]# cd freetype-2.1.5
[root@localhost freetype-2.1.5]# ./configure && make && make install
[root@localhost freetype-2.1.5]# cd ..

(4) libjpeg 설치
jpg 포맷을 다루는 라이브러리 입니다.
[root@localhost src]# wget http://ftp.superuser.co.kr/pub/etc/jpegsrc.v6b.tar.gz
[root@localhost src]# tar xvfz jpegsrc.v6b.tar.gz
[root@localhost src]# cd jpeg-6b
[root@localhost jpeg-6b]# ./configure --enable-shared --enable-static
[root@localhost jpeg-6b]# mkdir /usr/local/man/man1
[root@localhost jpeg-6b]# make && make test
[root@localhost jpeg-6b]# make install
[root@localhost jpeg-6b]# cd ..

(5) gd 설치
그래픽 라이브러리 입니다.
[root@localhost src]# wget http://ftp.superuser.co.kr/pub/etc/gd-2.0.15.tar.gz
[root@localhost src]# tar xvfz gd-2.0.15.tar.gz
[root@localhost src]# cd gd-2.0.15
[root@localhost gd-2.0.15]# ./configure && make && make install
[root@localhost gd-2.0.15]# cd ..

(6)<libmcrpt설처>
[root@localhost src]# wget ftp://ftp.superuser.co.kr/etc/libmcrypt-2.5.7.tar.gz
[root@localhost src]# tar xvfz libmcrypt-2.5.7.tar.gz
[root@localhost src]# cd libmcrypt-2.5.7
[root@localhost  libmcrypt-2.5.7]# ./confiure && make && make install
[root@localhost  libmcrypt-2.5.7]# cd ..

(7)<libxml설치>
[root@localhost src]# wget ftp://ftp.superuser.co.kr/etc/libxml2-2.6.16.tar.gz
[root@localhost src]# tar xvfz libxml2-2.6.16.tar.gz
[root@localhost src]# cd libxml2-2.6.16
[root@localhost libxml2-2.6.16]# ./confiure && make && make install
[root@localhost libxml2-2.6.16]# cd ..

(8)<curl설치>
[root@localhost src]# wget ftp://ftp.superuser.co.kr/etc/curl-7.14.0.tar.gz
[root@localhost src]# tar xvfz curl-7.14.0.tar.gz
[root@localhost src]# cd curl-7.14.0
[root@localhost curl-7.14.0]# ./confiure && make && make install
[root@localhost curl-7.14.0]# cd ..


(9) <imap 라이브러리를 쓰기 위해서 패키지 설치>
wget ftp://ftp.superuser.co.kr/redhat/9/RPMS/imap-2001a-18.i386.rpm
wget http://ftp.superuser.co.kr/pub/redhat/9/RPMS/imap-devel-2001a-18.i386.rpm
rpm -Uvh imap-2001a-18.i386.rpm
rpm -Uvh imap-devel-2001a-18.i386.rpm


(10)<freetds 설치>
www.freetds.org에서 다운로드
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static --with-tdsver=8.0

make
make install

## --with-tdsver=8.0 --> 연결할 mssql server가 mssql 2000 일때 8.0, mssql 7 은 7.0 이다

cd /usr/local/freetds
cp ./lib/* /usr/lib   라이브러리 파일을 복사한다
vi ./etc/freetds.conf  설정파일 수정

이부분을 주석(;)을 제거
[MyServer70]
        host = mssql server ip
        port = 1433
        tds version = 8.0 --a mssql 7 은 7.0





(11)<mysql 5.0.15>
CFLAGS="-static -O2 -march=i686 -funroll-loops" CXXFLAGS="-static -O2 -march=i686 -funroll-loops -felide-constructors -fno-exceptions -fno-rtti"\
./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--disable-shared \
--enable-assembler \
--with-thread-safe-client \
--with-mysqld-user="mysql" \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-readline\
 --without-debug\
 --without-docs\
 --without-bench\
 --with-charset=utf8

make
make install

※MySQL 4.1.X 에서는 --with-charset=euckr

메모리에 따라서 환경 설정 파일들을 복사해 줍니다.
my-huge.cnf 1~2G
my-large.cnf 512M
my-medium.cnf 128M~ 256M
my-small.cnf 64M 이하
cp /usr/local/mysql/share/mysql/my-large.cnf /etc/my.cnf

※innodb 사용시
vi /etc/my.cnf

innodb_flush_log_at_trx_commit=0

innodb_buffer_pool_size=850M (server ram 의 50%)


<기본 db 생성 >
/usr/local/mysql/bin/mysql_install_db

<mysql 운영 사용자 생성>
useradd -M mysql

<data 디렉토리를 mysql이라는 사용자 권한으로 바꾸어 주어야 합니다>
chown -R mysql:mysql /usr/local/mysql/data

<아무곳에서나 mysql 및 mysqldump 명령어를 실행가능하게 심볼릭 링크를 걸어줍니다.(웹호스팅시에 필요)>
ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/

<mysql 데몬을 실행>
/usr/local/mysql/bin/mysqld_safe &

<mysql root 비밀번호를 설정>
/usr/local/mysql/bin/mysqladmin -u root password "암호"

mysql -u root -p
 
<mysql 접속후 계정 생성>
mysql> use mysql
mysql> create database DB명;
mysql> desc db; (n갯수 확인) -> n이 DB권한 계정와 DB연결시 y 갯수와 동일
mysql> insert into user (host,user,password) values('localhost','계정',password('비번')); %-> 모든 ip
mysql> insert into db values('localhost','DB명','계정','y','y','y','y','y','y','y','y','y','y','y','y','y','y','y','y','y');
mysql> flush privileges;
mysql> select host, user, password from user; 로 확인..


(12-a) <apache 1.3.33>
반드시 src/include/httpd.h 수정후
#ifdef WIN32
#define HARD_SERVER_LIMIT 1024
#elif defined(NETWARE)
#define HARD_SERVER_LIMIT 2048
#else
#define HARD_SERVER_LIMIT 256 ---> 1024로 수정

./configure --prefix=/usr/local/apache --enable-module=so --enable-shared=max --enable-module=rewrite && make -j2 && make install

(12-b)<apache 2.2.4>
./configure --prefix=/usr/local/apache --enable-module=so --enable-shared=max --enable-rewrite && make -j2 && make install


(13)<아파치 설정화일>
AddType application/x-httpd-php .php .phtml .php3 .html .htm
AddType application/x-httpd-php-source .phps

DirectoryIndex index.html index.htm index.php index.php3 index.cgi

CustomLog logs/access_log common 이렇게 되어 있는 것을 ..
SetEnvIfNoCase Request_URI (gif|png|jpg|css|js|bmp|jpeg|swf)$ IMAGE=1
CustomLog /usr/local/apache/logs/access_log common env=!IMAGE

<Directory "/usr/local/apache/htdocs">
Options Indexes .... -> Options Includes 변경


(14) php-4.4.5 config옵션
CFLAGS="-O3 -march=i686 -funroll-loops -fomit-frame-pointer" \
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-gd --with-zlib-dir --with-gd --with-ttf --with-expat-dir=/usr --with-gmp \
--with-xml --with-mysql=/usr/local/mysql --with-language=korean \
--with-charset=euckr --disable-debug --disable-posix --disable-rpath \
--enable-safe-mode --enable-magic-quotes --disable-dmalloc \
--enable-bcmath --enable-dio --enable-gd-native-ttf --enable-sysvsem \
--enable-sysvshm --enable-wddx --enable-versioning --enable-pic \
--enable-inline-optimization --enable-mbstring --enable-mbregex \
--enable-mbstr-enc-trans --with-config-file-path=/usr/local/lib --enable-ftp \
--disable-debug --with-gif-dir=/usr/lib --with-png-dir \
--enable-track-vars=yes --with-jpeg-dir --with-freetype-dir \
--enable-gd-native-ttf --enable-dl --with-imap=shared \
--with-mcrypt --with-imap-ssl=/usr/lib --with-kerberos \
--with-openssl=/usr --enable-socket --with-sybase=/usr/local/freetds --with-curl

<php 5.0.5>
CFLAGS="-O3 -march=i686 -funroll-loops -fomit-frame-pointer" \
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-gd=/usr/local/src/gd \
--with-jpeg-dir=/usr/local/src/jpeg \
--with-zlib-dir --with-gd --with-ttf --with-expat-dir=/usr \
--with-gmp --with-xml --with-mysql=/usr/local/mysql \
--with-language=korean \
--with-charset=euc_kr \
--disable-debug \
--disable-posix --disable-rpath --enable-safe-mode \
--enable-magic-quotes --disable-dmalloc \
--enable-bcmath \
--enable-dio --enable-gd-native-ttf \
--enable-sysvsem --enable-sysvshm \
--enable-wddx --enable-versioning \
--enable-pic --enable-inline-optimization \
--enable-mbstring --enable-mbregex --enable-mbstr-enc-trans \
--with-config-file-path=/usr/local/apache/conf
--enable-ftp \
--disable-debug \
--with-gif-dir=/usr/lib \
--with-png-dir \
--enable-track-vars=yes  \
--with-jpeg-dir --with-freetype-dir \
--enable-gd-native-ttf \
--with-curl
--enable-dl \
--with-imap=shared \
--with-mcrypt \
--with-libxml2-dir=/usr/local/src/libxml2
--with-imap-ssl=/usr/lib \
--with-kerberos \
--with-openssl=/usr \
--enable-socket \
--with-sybase=/usr/local/freetds \
--enable-sigchild && make -j2 && make install

(15)<php.ini>복사
cp php.ini-dist /usr/local/lib/php.ini

** php.ini파일은 /usr/local/apache/conf/ 디렉토리에도 생성해줘야 한다..

** Zend 설치 전 php.ini 파일수정 **

<php설정화일>
register_globals=On
default_socket_timeout = 600
post_max_size = 20M
memory_limit = 20M
upload_max_filesize = 20M

<Zend optimizer설치>
wget http://ftp.superuser.co.kr/pub/ZendOptimizer/ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz
압축푼후 ./install
-----------> php.ini 파일 위치는 반드시 /usr/local/lib 로 잡는다..

cd /usr/local/apache/conf
ln -s /usr/local/lib/php.ini ./
/usr/local/apache/bin/apachectl restart

테스트 vi /usr/local/apache/htdocs/test.php

<? phpinfo(); ?>

http://ip/test.php로 확인

** 확인사항
configuration file --> /usr/local/Zend/etc/php.ini 확인
safe_mode 가 off로 돼있어야 함..