사이트 내 전체검색
PHP
[PHP] PHP5와 Zend 컴파일 A to Z (2009-11-03 수정)
로빈아빠
https://cmd.kr/php/667 URL이 복사되었습니다.

본문

mySQL  : http://happyjung.com/gnuboard/bbs/board.php?bo_table=lecture&wr_id=782 
Apache : http://happyjung.com/gnuboard/bbs/board.php?bo_table=lecture&wr_id=784 
GD설치 : http://happyjung.com/gnuboard/bbs/board.php?bo_table=lecture&wr_id=235 
PHP5    :             ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓  본문참고 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


1. libzml2 설치
가능하면 [ 방법2 ]를 이용하세요.
[ 방법1 ]
1-1. rpm 설치된 libxml2 확인후 삭제
[root@localhost local]# rpm -qa | grep libxml2
libxml2-2.6.16-12
libxml2-python-2.6.16-12
<주의>
[root@localhost local]# rpm -e --nodeps libxml2-2.6.16-12  <<== 이렇게 지우면 고생합니다.
[root@localhost local]# rpm -e libxml2-2.6.16-12  <<== 이렇게 지우세요.


1-2. libxml2 설치
[root@localhost local]# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
[root@localhost local]# tar zxvfp libxml2-2.7.3.tar.gz
[root@localhost local]# cd libxml2-2.7.3
[root@localhost libxml2-2.7.3]# ./configure --prefix=/usr/local/libxml2
[root@localhost libxml2-2.7.3]# make && make install
[root@localhost libxml2-2.7.3]# make clean
[root@localhost libxml2-2.7.3]# cp /usr/local/libxml2/lib/libxml2.so.2.7.3 /usr/local/lib
[root@localhost libxml2-2.7.3]# cd /usr/local/lib
[root@localhost lib]# ln -s libxml2.so.2.7.3 libxml2.so
[root@localhost lib]# ln -s libxml2.so.2.7.3 libxml2.so.2
[root@localhost lib]# cd ..

[ 방법2 ]
[root@localhost local]# yum install libxml2-devel


2. zlib 설치
2-1. zlib 다운로드 및 rpm 삭제
[root@localhost local]# wget http://www.zlib.net/zlib-1.2.3.tar.gz
[root@localhost local]# rpm -qa | grep zlib
zlib-devel-1.2.1.2-1.2
zlib-1.2.1.2-1.2
<주의>
[root@localhost local]# rpm -e --nodeps zlib-1.2.1.2-1.2  <<== 이렇게 지우면 고생합니다.
[root@localhost local]# rpm -e zlib-1.2.1.2-1.2  <<== 이렇게 지우세요.

2-3. zlib 설치
[root@localhost local]# tar zxvf zlib-1.2.3.tar.gz
[root@localhost local]# cd zlib-1.2.3
[root@localhost zlib-1.2.3]# ./configure -s // libz.so 동적모듈생성 -s 는 -shared  의 줄임말
[root@localhost zlib-1.2.3]# make
[root@localhost zlib-1.2.3]# ./configure // libz.a 정적모듈생성
[root@localhost zlib-1.2.3]# make test
[root@localhost zlib-1.2.3]# make install
[root@localhost zlib-1.2.3]# cp libz.so* /usr/lib
[root@localhost zlib-1.2.3]# cp libz.so* /usr/local/lib
[root@localhost zlib-1.2.3]# cd /usr/local/lib
[root@localhost lib]# rm -f libz.so
[root@localhost lib]# rm -f libz.so.1
[root@localhost lib]# ln -s libz.so.1.2.3 libz.so
[root@localhost lib]# ln -s libz.so.1.2.3 libz.so.1
[root@localhost lib]# cd ..


3. PHP 다운로드
[root@localhost local]# wget http://kr.php.net/get/php-5.2.11.tar.gz/from/kr.php.net/mirror 
[root@localhost local]# tar zxvfp php-5.2.11.tar.gz
[root@localhost local]# cd php-5.2.11


4. PHP 컴파일
[root@localhost php-5.2.11]# ./configure \
--prefix=/usr/local/php \
--with-exec-dir=/usr/local/apache/bin \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/bin/mysql_config \
--disable-debug \
--enable-dom \
--enable-exif \
--with-freetype-dir \
--enable-ftp \
--enable-gd-native-ttf \
--with-gd \
--with-iconv \
--enable-inline-optimization \
--with-jpeg-dir \
--enable-magic-quotes \
--enable-mbregex \
--enable-mbstring=all \
--with-mcrypt=/usr \
--with-pear \
--with-png-dir \
--with-ttf \
--enable-xml \
--with-xmlrpc \
--with-xpm-dir \
--with-zlib \
--with-zlib-dir

prefix 지정하지 않는경우에는 /usr/local/lib/php 에 설치됩니다.

기타 옵션
--with-bz2 \
--enable-calendar \
--with-gdbm \
--with-db4 \
--with-mhash \
--with-snmp \
--with-xsl \
--with-libxml-dir=/usr/local/lib \
--with-zlib \
--enable-soap \
--enable-sockets

5. 컴파일 오류시 대처하기
5-1. configure: error: xml2-config not found. Please check your libxml2 installation.  에러날때
[root@localhost php-5.2.11]# yum install libxml2-devel

5-2. configure: error: Please reinstall the BZip2 distribution   에러날때
해결책 :
[root@localhost local]# wget ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz
Bzip2팩키지는 configure script가 없습니다. option을 한줄로 써서 컴파일 하고 설치합니다.
[root@localhost local]# cd bzip2-1.0.2
[root@localhost bzip2-1.0.2]# make PREFIX=/tools install
[root@localhost bzip2-1.0.2]# make clean
[root@localhost bzip2-1.0.2]# cd ../php-5.2.11

5-3. configure: error: libXpm.(a|so) not found   에러날때
[root@localhost php-5.2.11]# yum install xorg-x11-devel

5-4. configure: error: mcrypt.h not found. Please reinstall libmcrypt.   에러날때
[root@localhost php-5.2.11]# cd ..
[root@localhost local]# wget http://ftp.linux.co.kr/pub/etc/libmcrypt-2.5.7.tar.gz
[root@localhost local]# tar zxvfp libmcrypt-2.5.7.tar.gz
[root@localhost local]# cd libmcrypt-2.5.7
[root@localhost libmcrypt-2.5.7]# ./configure && make && make install
[root@localhost libmcrypt-2.5.7]# cd ../php-5.2.11

5-5. /usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1   오류가 날때
[root@localhost php-5.2.11]# cd ..
[root@localhost local]# wget http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
[root@localhost local]# cd libtool-2.2.6
[root@localhost libtool-2.2.6]# ./configure
[root@localhost libtool-2.2.6]# make
[root@localhost libtool-2.2.6]# make install
[root@localhost libtool-2.2.6]# cd ../php-5.2.11

6. PHP 설치
<나눠서 실행하기>
[root@localhost php-5.2.11]# make
[root@localhost php-5.2.11]# make test
[root@localhost php-5.2.11]# make install
<한번에 실행하기>
[root@localhost php-5.2.11]# make && make test && make install
[root@localhost php-5.2.11]# make clean


7. php 환경설정 파일 복사
<주의>
[root@localhost php-5.2.11]# cp php.ini-dist /etc/php.ini  
위의 경로에 복사하면 Zend 설치오류발생하므로 가급적 아래 경로를 사용하세요.
[root@localhost php-5.2.11]# cp php.ini-dist /usr/local/php/lib

PHP 확장자 옵션 추가
[root@localhost php-5.2.11]# vi /usr/local/apache/conf/httpd.conf
...
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php     # index.htm index.php 추가
</IfModule>
...
<IfModule mime_module>
    # php 관련 2줄 추가
    AddType application/x-httpd-php .php .php3 .php4 .htm .html .inc
    AddType application/x-httpd-php-source .phps
...
[root@localhost php-5.2.11]# /usr/local/apache/bin/apachectl restart

[root@localhost php-5.2.11]# vi ~/.bash_profile
...
PATH=$PATH:$HOME/bin:/usr/lib:/user/local/mysql/bin:/usr/local/apache/bin:/usr/local/php/bin
...
[root@localhost php-5.2.11]# source ~/.bash_profile


5. Zend 설치
http://www.zend.com 에서 ZendOptimizer 다운로드

5-1. ZendOptimizer-3.3.3 설치하기 ( 다운로드 : http://yyman.tistory.com/116 )
[root@localhost local]# tar zxvfp ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
[root@localhost local]# cd ZendOptimizer-3.3.3-linux-glibc23-i386
[root@localhost ZendOptimizer-3.3.3-linux-glibc23-i386]# ./install.sh
자동설치후
[root@localhost ZendOptimizer-3.3.3-linux-glibc23-i386]# cd /usr/local/php/lib
[root@localhost lib]# ln -s /usr/local/Zend/etc/php.ini


5-2. ZendOptimizer-3.3.9 설치하기
참고 : http://blog.naver.com/01191879872?Redirect=Log&logNo=10070903354

5-3. 설정
[root@localhost lib]# vi /usr/local/Zend/etc/php.ini
...
register_globals = Off   -->  On
post_max_size = 8M   -->  30M
upload_max_filesize = 2M   -->   30MB
...
[root@localhost lib]# /usr/local/apache/bin/apachectl restart

모든 설치가 끝났습니다.
# cd /home/wmaster/html
# vi test.php
<? phpinfo(); ?>

[실패]
This program makes use of the Zend scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

[성공]
This program makes use of the Zend scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies


6. php.ini 설정변경
[root@localhost lib]# vi /usr/local/Zend/etc/php.ini
...
allow_url_fopen = On   -->  Off
...
[root@localhost lib]# /usr/local/apache/bin/apachectl restart
해당 옵션을 On으로 설정하면 파일 엑세스시 외부 사이트의 파일을 호출할수 있습니다.
특히 include(), require() 계열의 함수 사용시 심각한 보안상 문제를 유발할수 있습니다.
php injection 과 관련이 있습니다.


참고자료
http://blog.naver.com/norther80/80010370985
http://jis.pe.kr/road/entry/리눅스-APM-소스설치시-에러에-대한-대처
네이버 지식인 (smson92 님)
http://yyman.tistory.com/116
http://tong.nate.com/ko1047/23998133
http://www.phpkorea.org/archives/305 

댓글목록

등록된 댓글이 없습니다.

PHP
871 (6/18P)

Search

Copyright © Cmd 명령어 3.136.22.204