wdcsx 发表于 2015-8-28 13:21:22

php mcrypt 完全安装

  今天安装完 PHP ,访问某个功能时,/var/log/httpd/error_log中报如下错误:
  PHP Fatal error:Call to undefined function mcrypt_get_block_size() in /var/www/html/miniblog/system/classes/class_DES.php on line 40
  
  心想必是 mcrypt没有安装
  
  
  安装步骤如下:
  1.查看当前php 版本#php -version
  2.如果当前linux 中有php的源码包最好,如果没有源码包,需要去下载一个原码包,上传到服务器解压
  3.确认是否已安装libmcrypt
   ldconfig -p | grep libmcrypt
  如果没有安装:
下载地址:http://sourceforge.net/projects/mcrypt
可以同时下载libmcrypt 和 mcrypt
先安装libmcrypt, 默认安装目录为 /usr/local , PHP 手册建议--disable-posix-threads ,不知何故
./configure && make && make install
ldconfig
  再安装mcrypt, 默认安装目录为 /usr/local
./configure --with-libmcrypt-prefix=/usr/local
  4. 确认是否已安装mhash
   ldconfig -p | grep mhash
  如果没有安装:
   下载地址:http://mhash.sourceforge.net/
   ./configure && make && make install
    ldconfig
  5.进入源码目录,安装mcrypt模块,这一步会生成一个mcrypt.so文件
   cd php-x.x.x/ext/mcrypt
   ./configure --with-mcrypt=/usr/local/ && make && make install
  6.在/etc/php.ini最后面加上一行:extension=/usr/lib/php/modules/mcrypt.so
  7.重启php    #service httpd restart
页: [1]
查看完整版本: php mcrypt 完全安装