步驟:
1.從php.net上面下載php5.3.x版本的源碼;
2.centos安裝相應的擴展包:
yum install libmcrypt libmcrypt-devel mcrypt mhash
下面的開發環境是為了編譯整個php源碼準備的環境,此次編譯mcrypt擴展不需要執行.
yum install -y httpd-devel libtool-ltdl libtool-ltdl-devel openssl-devel curl-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \
libc-client libc-client-devel gd gd-devel libmcrypt libmcrypt-devel \
sqlite sqlite-devel mysql-devel libicu libicu-devel pcre-devel
3.確定phpize有安裝到服務器:
whereis phpize
確定php-config的位置:
whereis php-config
執行:
./configure –with-php-config=/usr/bin/php-config
4.make錯誤:
mcrypt.c:283: error: ‘PHP_FE_END' undeclared here (not in a function)
解決方法:
sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' ./ext/**/*.c
make
如果是ZEND_MOD_END的錯誤,則執行:
sed -i 's|ZEND_MOD_END|{NULL,NULL,NULL}|' ./ext/**/*.c
5.執行下 make test,測試沒有問題.再執行:
make install
6.增加文件: /etc/php.d/mcrypt.ini
; Enable mbstring extension module
extension=mcrypt.so
7.重啟web服務器,檢查php mcrypt是否安裝成功.