2011. 7. 13. 13:30

PHP에 MCRYPT 모듈 설치(DSO)

yum으로 설치하지 않는 apache, php의 경우 추가 방법, PHP소스가 필요합니다.

1. mhash 모듈 설치

 yum install mhash* 을 하거나(추천) 파일을 다운받아 configure & make & makeinstall

2. libmcrypt 모듈 설치

yum install libmcrypt* 을 하거나 (추천)

mcrypt 모듈 소스 설치 ---------------------------------
파일을 다운받아(소스포지) configure & make & makeinstall -> 이 경우 /etc/ld.so.conf 에 /usr/local/lib 경로 추가 후 ldconfig 실행
소스포지에서 파일 다운로드 후 압축 해제
configure
make
make install 을 하면 파일이 /usr/local/bin/mcrypt 와 같이 생성됨
----------------- 소스설치끝

php소스/ext/mcrypt 로 이동하여
phpize
aclocal
configure --with-php-config=/usr/local/php/bin/php-config
make clean
make 
make install
순으로 명령을 실행하면 특정폴더에 mcrypt.so 파일을 생성했다는 내용이 나옮니다.
보통은 /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ 와 같이 생성
해당 폴더로 이동해 보면 mcrypt.so 파일이 존재 하는데 해당 파일을 php extension 디렉토리로 옮기고
php.ini 에 extension=mcrypt.so 처럼 하거나 다른 디렉토리에 복사했을 경우 경로를 다 적어주면 됨
extension=/usr/local/lib/php/extensions/mcrypt.so
그후 아파치 리스타트!!


---------------------------------------------------------------------------------------------------
참고

Get and Install mhash

wget http://internap.dl.sourceforge.net/sourceforge/mhash/mhash-0.9.9.9.tar.gz
or go to sourceforge and find the latest.

tar -xvzf mhash-0.9.9.tar.gz
cd mhash-0.9.9
./configure --prefix=/usr/local/mhash
make
make install

Get and install libmcrypt

wget http://jaist.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar -xvzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt --disable-posix-threads
make
make install

Get and install mcrypt.

wget http://cdnetworks-kr-1.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
or go to source forge and get the latest.

tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make
make install


Create the mcrypt php5 module to load.

Find you source code for your php version.

use: find / -name "php"

mine was found here /usr/src/redhat/SOURCES/php-5.1.6/

cd to php-5.2.6/ext/mcrypt
phpize
aclocal
./configure
make clean
make
make install


If you are using a 64 bit computer, create a symbolic link.
cd /usr/lib64/modules
ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20050922/mcrypt.so ./mcrypt.so

Create a new file named mcrypt.so in /etc/php.d directory and enter the following.

;Enable mcrypt extension module
extension=mcrypt.so

Create the mhash extension:

cd to php-5.2.6/ext/mhash
phpize
aclocal
./configure
make clean
make
make install

cd /usr/lib64/modules
[root modules]# ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20050922/mhash.so ./mhash.so

Create a new file named mcrypt.so in /etc/php.d directory and enter the following.

;Enable mhash extension module
extension=mhash.so

Bounce Apache
[root /]#service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Check Apache for mcrypt loaded.
Move to your website loaction and create a file named phpinfo.php and enter.

<?=phpinfo();?>

Now open a brower and point it to your site /phpinfo.php

Look for a section named mcrypt and mhash, they should show the version, supported ciphers, enabled, etc.