一.編譯安裝mcrypt
1.先安裝libmcrypt
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install
2.安裝mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
3.安裝mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make
#make install
#cd /usr/local/src/php-5.3.16/ext/mcrypt/
切換到php安裝目錄的etx/openssl目錄
#cd /usr/local/src/php-5.3.16/ext/openssl
openssl目錄下有個config.w32和config0.m4,把config0.m4改名爲config.m4(原因不解釋)
#mv config0.m4 config.m4
#/usr/local/bin/phpize(或$PHP_PREFIX/bin/phpize)
#./configure --with-openssl --with-php-config=/usr/local/php5/bin/php-config
#make
#make test
#make install
在php.ini內加入以下內容:
extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "openssl.so"
重啓php、nginx後生效
#ps aux | grep php
#killall php-fpm
#/usr/local/php5/sbin/php-fpm &
#/etc/init.d/nginx restart
#/usr/local/php5/bin/php -i |grep openssl(查看openssl)
訪問phpinfo頁面即可顯示出已加載mcrypt和openssl模塊
配置過程中遇到的問題:
1.安裝好模塊後phpinfo無顯示,經查看,phpinfo顯示的php版本可服務器上php -v顯示的不一樣,安裝了兩個版本導致的 。
解決方法:cp /etc/php.ini /usr/local/php5/etc/php.ini,然後重啓nginx和php-fpm
2.安裝好openssl模塊後phpinfo顯示disabled
解決方法:把服務器上所有的php.ini都加以修改,並重啓nginx和php-fpm