系統環境:centOS6.3
APACHE:httpd-2.4.2
PHP:php-5.3.21
一.安裝mcrypt
1.下載Libmcrypt,mhash,mcrypt安裝包
復制代碼 代碼如下:
libmcrypt-2.5.8.tar.gz
# wget http://sourceforge.net/project/showfiles.php?group_id=87941&package_id=91774&release_id=487459
mhash-0.9.9.tar.gz
# wget http://sourceforge.net/project/showfiles.php?group_id=4286&package_id=4300&release_id=645636
mcrypt-2.6.8.tar.gz
# wget http://sourceforge.net/project/showfiles.php?group_id=87941&package_id=91948&release_id=642101
2 .先安裝Libmcrypt
復制代碼 代碼如下:
# tar -zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# /usr/local/php5/bin/phpize #動態編譯php模塊,使其可以使用configure編譯。
# ./configure
# make
# make install # libmcript默認安裝在/usr/local
3.安裝mhash
復制代碼 代碼如下:
# tar -zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9
# /usr/local/php5/bin/phpize
# ./configure
# make
# make install
4.安裝mcrypt
復制代碼 代碼如下:
# tar -zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /usr/local/php5/bin/phpize
# ./configure --with-php-config=/usr/local/php5/bin/php-config
# make
# make install
安裝完畢,按照編譯安裝後的提示
mcrypt.so模塊會默認保存在 /usr/local/php5/lib/php/extensions/no-debug-zts-20090626/ 目錄下
5.加載該模塊到php
復制代碼 代碼如下:
# vi /usr/local/php5/lib/php.ini
添加如下行:
復制代碼 代碼如下:
extension = "/usr/local/php5/lib/php/extensions/no-debug-zts-20090626/mcrypt.so"
重啟apache:
復制代碼 代碼如下:
/usr/local/apache2/bin/apachectl restart
6.添加phpinfo功能,測試頁面
添加以下內容info.php到/usr/local/apache2/htdocs/下,測試php模塊是否加載.
復制代碼 代碼如下:# vi /usr/local/apache2/htdocs/info.php
---------------
<?php
echo phpinfo();
?>
---------------
檢查80端口是否打開
復制代碼 代碼如下:
# lsof -i:80
浏覽器輸入 http://localhost/info.php
顯示有如下測試頁面內容, mcrypt.so模塊即在PHP下加載成功