---
title: "centos安装php的mcrypt扩展"
author: "tw5566"
date: "2014-07-23T11:43:33Z"
tags: []
categories: ["操作系统"]
slug: "centos-php-mcrypt"
draft: false
lastmod: "2014-07-23T11:43:33Z"
id: 2095398
url: "https://tw5566.iteye.com/blog/2095398"
---

博客：http://ju.outofmemory.cn/entry/9241

安装php的mcrypt扩展(动态加载编译)

 

centos中安装phpize

使用命令

yum install php-devel

然后就会安装上phpize了

下载php下的mcrypt扩展或者直接下载php的完整安装包  
http://www.php.net/releases/ 网页下找到自己服务器的php版本，下载后tar解压（本人的是php5.3.3）  
进入ext/mcrypt文件夹  
上传 mcrypt文件夹到你服务器的某个目录下然后进入此目录  
执行phpize命令（phpize是用来扩展php扩展模块的，通过phpize可以建立php的外挂模块，如果没有？yum install php53-devel里包含了，或者其他方法）

\[root@\*\_\*14:48 mcrypt]# whereis phpize    //为了确定phpize存在

phpize:/usr/bin/phpize /usr/share/man/man1/phpize.1.gz

\[root@\*\_\*14:48 mcrypt]# phpize

Configuringfor:

PHP ApiVersion:         20090626

ZendModuleApiNo:      20090626

ZendExtensionApiNo:   220090626

执行完后，会发现当前目录下多了一些configure文件，最后执行php-config命令就基本完成了

执行以下命令，确保你的/usr/bin/php-config是存在的

\[root@\*\_\*15:02 mcrypt]# whereis php-config

php-config:/usr/bin/php-config /usr/share/man/man1/php-config.1.gz

\[root@\*\_\*15:02 mcrypt]#./configure --with-php-config=/usr/bin/php-config

如果遇到以下错误，请先安装gcc，命令yum install gcc  
&lt;!--\[if !supportLineBreakNewLine]--&gt;  
&lt;!--\[endif]--&gt;

configure: error:no acceptable C compiler found in $PATH

直到不报错，出现：config.status: creating config.h，执行以下命令  
&lt;!--\[if !supportLineBreakNewLine]--&gt;  
&lt;!--\[endif]--&gt;

\[root@\*\_\*15:06 mcrypt]# make && make install

最后的最后，会提示你如下，说明你大功告成了  
&lt;!--\[if !supportLineBreakNewLine]--&gt;  
&lt;!--\[endif]--&gt;

Installing shared extensions:     /usr/lib64/php/modules/

顺便检查下/usr/lib64/php/modules/里的mrcypt.so扩展是否已经创建成功  
然后的事就简单了，给你的php.ini添加一条extension=mcrypt.so  
&lt;!--\[if !supportLineBreakNewLine]--&gt;  
&lt;!--\[endif]--&gt;

\[root@\*\_\*15:09 mcrypt]# cd /etc/php.d

创建一个mrcypt.ini文件就行，里面写extension=mcrypt.so  
&lt;!--\[if !supportLineBreakNewLine]--&gt;  
&lt;!--\[endif]--&gt;

\[root@\*\_\*15:17 php.d]# echo 'extension=mcrypt.so'&gt; mcrypt.ini

 

(3) 、重启apache，查阅phpinfo，mcrypt模块扩展是不是加载了？