新裝了centos 6.2,用yum安裝的php,發現少了mbstring、mcrypt擴充,可是在centos的repos裡不再包括mcrypt的源檔案,於是
1、下載php-5.3.11.tar.gz,找到ext/mcrypt,用phpize來進行擴充,發現phpize不能用;
2、rpm -q --whatprovides /usr/bin/phpize找出需要安裝php-devel,
yum安裝php-devel,可以phpize;
3、phpize、./configure編譯mcrypt.so,告訴缺少mcrypt.h
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
mkdir -p /usr/local/libmcrypt
./configure prefix=/usr/local/libmcrypt/
make
make install
4、再./configure,警告You will need re2c 0.13.4 or later if you want to regenerate PHP parsers
wget http://pkgs.repoforge.org/re2c/re2c-0.13.5-1.el6.rf.x86_64.rpm
rpm -i re2c-0.13.5-1.el6.rf.x86_64.rpm
還是缺少mcrypt.h,從/usr/local/libmcrypt/include下把mcrypt.h複製過去仍然不行
5、把mcrypt.h複製到/usr/include,再./configure提示無法確定libmcrypt的版本
6、重新編譯libmcrypt後可以正常./configure了,但make出錯
mcrypt.c:283: error: ‘PHP_FE_END’ undeclared here (not in a function)
7、原始碼有錯誤,進入php-5.3.11目錄
sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' ./ext/**/*.c
sed -i 's|ZEND_MOD_END|{NULL,NULL,NULL}|' ./ext/**/*.c
再編譯安裝,一切正常了
8、測試phpmyadmin,提示“無法載入 mcrypt 擴充,<br />請檢查 PHP 配置”
9、編輯/etc/php.ini,加入
extension=/usr/lib64/php/modules/mcrypt.so
問題解決。