찾다
php教程php手册CentOS下php安装mcrypt扩展
CentOS下php安装mcrypt扩展Jun 06, 2016 am 09:46 AM
centosmcryptphp암호설치하다오픈 소스확장하다프로그램 작성프로그래밍 언어소프트웨어 개발

(以下步骤均为本人实际操作,可能与你的安装方法有所区别,但我会尽量排除疑惑)

大致步骤(1)安装mcrypt,(2)安装php对mcrypt的扩展,(3)重启apache

(1)、确认你的linux没有安装mcrypt库,如果已安装,跳过安装步骤

[root@test-<span style="color: #800080;">206</span> ~]# yum list installed|<span style="color: #0000ff;">grep</span><span style="color: #000000;"> mcrypt
libmcrypt.x86_64                          </span><span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span><span style="color: #000000;">.el5.centos           installed
libmcrypt</span>-devel.x86_64                    <span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span><span style="color: #000000;">.el5.centos           installed
mcrypt.x86_64                             </span><span style="color: #800080;">2.6</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">1</span>.el5                  installed

以上显示已经安装过,若没有,则按以下两种方式安装

(方法一)yum命令懒人安装

yum <span style="color: #0000ff;">install</span> libmcrypt libmcrypt-devel mcrypt mhash

执行后会显示即将安装的相关库,你可以根据你的linux限定x86_64或者i386,如yum install libmcrypt.x86_64(如果yum命令无法连接仓库,请检查你的/etc/yum.repos.d/里的文件正确性,以及你的/etc/host是不是可达里面的域名)

<span style="color: #000000;">Dependencies Resolved

</span>================================================================================<span style="color: #000000;">
 Package              Arch        Version                   Repository     Size
</span>================================================================================<span style="color: #000000;">
Installing:
 libmcrypt            i386        </span><span style="color: #800080;">2.5</span>.<span style="color: #800080;">7</span>-<span style="color: #800080;">5</span>.el5               epel          <span style="color: #800080;">124</span><span style="color: #000000;"> k
 libmcrypt            x86_64      </span><span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span>.el5.centos        extras        <span style="color: #800080;">105</span><span style="color: #000000;"> k
 libmcrypt</span>-devel      i386        <span style="color: #800080;">2.5</span>.<span style="color: #800080;">7</span>-<span style="color: #800080;">5</span>.el5               epel          <span style="color: #800080;">103</span><span style="color: #000000;"> k
 libmcrypt</span>-devel      x86_64      <span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span>.el5.centos        extras         <span style="color: #800080;">10</span><span style="color: #000000;"> k
 mcrypt               x86_64      </span><span style="color: #800080;">2.6</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">1</span>.el5               epel           <span style="color: #800080;">88</span><span style="color: #000000;"> k
 mhash                i386        </span><span style="color: #800080;">0.9</span>.<span style="color: #800080;">2</span>-<span style="color: #800080;">6</span>.el5               epel          <span style="color: #800080;">141</span><span style="color: #000000;"> k
 mhash                x86_64      </span><span style="color: #800080;">0.9</span>.<span style="color: #800080;">9</span>-<span style="color: #800080;">1</span>.el5.rf            rpmforge      <span style="color: #800080;">161</span><span style="color: #000000;"> k

Transaction Summary
</span>================================================================================<span style="color: #000000;">
Install       </span><span style="color: #800080;">7</span><span style="color: #000000;"> Package(s)
Upgrade       </span><span style="color: #800080;">0</span><span style="color: #000000;"> Package(s)

Total download size: </span><span style="color: #800080;">731</span><span style="color: #000000;"> k
Is this ok [y</span>/N]:

确定安装,最后显示

<span style="color: #000000;">Installed:
  libmcrypt.x86_64 </span><span style="color: #800080;">0</span>:<span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span><span style="color: #000000;">.el5.centos
  libmcrypt</span>-devel.x86_64 <span style="color: #800080;">0</span>:<span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">4</span><span style="color: #000000;">.el5.centos
  mcrypt.x86_64 </span><span style="color: #800080;">0</span>:<span style="color: #800080;">2.6</span>.<span style="color: #800080;">8</span>-<span style="color: #800080;">1</span><span style="color: #000000;">.el5
  mhash.x86_64 </span><span style="color: #800080;">0</span>:<span style="color: #800080;">0.9</span>.<span style="color: #800080;">9</span>-<span style="color: #800080;">1</span><span style="color: #000000;">.el5.rf

Complete</span>!

(方法二)源码编译安装,去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 
libmcrypt(libmcrypt-2.5.8.tar.gz ):
mcrypt(mcrypt-2.6.8.tar.gz ):
  mhash(mhash-0.9.9.9.tar.gz ):
2 .先安装Libmcrypt

#<span style="color: #0000ff;">tar</span> -zxvf libmcrypt-<span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span>.<span style="color: #0000ff;">tar</span><span style="color: #000000;">.gz
#cd libmcrypt</span>-<span style="color: #800080;">2.5</span>.<span style="color: #800080;">8</span><span style="color: #000000;">
#.</span>/<span style="color: #000000;">configure
#</span><span style="color: #0000ff;">make</span><span style="color: #000000;">
#</span><span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span> 说明:libmcript默认安装在/usr/local 


3.安装mhash

#<span style="color: #0000ff;">tar</span> -zxvf mhash-<span style="color: #800080;">0.9</span>.<span style="color: #800080;">9.9</span>.<span style="color: #0000ff;">tar</span><span style="color: #000000;">.gz
#cd mhash</span>-<span style="color: #800080;">0.9</span>.<span style="color: #800080;">9.9</span><span style="color: #000000;">
#.</span>/<span style="color: #000000;">configure
#</span><span style="color: #0000ff;">make</span><span style="color: #000000;">
#</span><span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>

4.安装mcrypt

#<span style="color: #0000ff;">tar</span> -zxvf mcrypt-<span style="color: #800080;">2.6</span>.<span style="color: #800080;">8</span>.<span style="color: #0000ff;">tar</span><span style="color: #000000;">.gz
#cd mcrypt</span>-<span style="color: #800080;">2.6</span>.<span style="color: #800080;">8</span><span style="color: #000000;">
#LD_LIBRARY_PATH</span>=/usr/local/lib ./<span style="color: #000000;">configure
#</span><span style="color: #0000ff;">make</span><span style="color: #000000;">
#</span><span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>

最后,还是检查下,是否安装成功

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

下载php下的mcrypt扩展或者直接下载php的完整安装包

http://cn.php.net/releases/ 网页下找到自己服务器的php版本,下载后tar解压(本人的是php5.3.3)

进入ext/mcrypt文件夹

[root@*_* <span style="color: #800080;">14</span>:<span style="color: #800080;">45</span> ~]# cd php-<span style="color: #800080;">5.3</span>.<span style="color: #800080;">3</span>/ext/mcrypt/

执行phpize命令(phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块,如果没有?yum install php53-devel里包含了,或者其他方法)

[root@*_* <span style="color: #800080;">14</span>:<span style="color: #800080;">48</span> mcrypt]# <span style="color: #0000ff;">whereis</span><span style="color: #000000;"> phpize    //为了确定phpize存在
phpize: </span>/usr/bin/phpize /usr/share/<span style="color: #0000ff;">man</span>/man1/phpize.<span style="color: #800080;">1</span><span style="color: #000000;">.gz
[root@</span>*_* <span style="color: #800080;">14</span>:<span style="color: #800080;">48</span><span style="color: #000000;"> mcrypt]# phpize
Configuring </span><span style="color: #0000ff;">for</span><span style="color: #000000;">:
PHP Api Version:         </span><span style="color: #800080;">20090626</span><span style="color: #000000;">
Zend Module Api No:      </span><span style="color: #800080;">20090626</span><span style="color: #000000;">
Zend Extension Api No:   </span><span style="color: #800080;">220090626</span>

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

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

[root@*_* <span style="color: #800080;">15</span>:<span style="color: #800080;">02</span> mcrypt]# <span style="color: #0000ff;">whereis</span> php-<span style="color: #000000;">config
php</span>-config: /usr/bin/php-config /usr/share/<span style="color: #0000ff;">man</span>/man1/php-config.<span style="color: #800080;">1</span><span style="color: #000000;">.gz
[root@</span>*_* <span style="color: #800080;">15</span>:<span style="color: #800080;">02</span> mcrypt]# ./configure --with-php-config=/usr/bin/php-config

如果遇到以下错误,请先安装gcc,命令yum install gcc

configure: error: no acceptable C compiler found <span style="color: #0000ff;">in</span> $PATH

直到不报错,出现:config.status: creating config.h,执行以下命令

[root@*_* <span style="color: #800080;">15</span>:<span style="color: #800080;">06</span> mcrypt]# <span style="color: #0000ff;">make</span> && <span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>

最后的最后,会提示你如下,说明你大功告成了

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

顺便检查下/usr/lib64/php/modules/里的mrcypt.so扩展是否已经创建成功

然后的事就简单了,给你的php.ini添加一条extension=mcrypt.so

[root@*_* <span style="color: #800080;">15</span>:<span style="color: #800080;">09</span> mcrypt]# cd /etc/php.d

创建一个mrcypt.ini文件就行,里面写extension=mcrypt.so

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

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

 

 

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
centos用什么命令可查版本号centos用什么命令可查版本号Mar 03, 2022 pm 06:10 PM

查版本号的命令:1、“cat /etc/issue”或“cat /etc/redhat-release”,可输出centos版本号;2、“cat /proc/version”、“uname -a”或“uname -r”,可输出内核版本号。

centos重启网卡的方法是什么centos重启网卡的方法是什么Feb 22, 2023 pm 04:00 PM

centos重启网卡的方法:1、对于centos6的网卡重启命令是“service network restart”;2、对于centos7的网卡重启命令是“systemctl restart network”。

centos php怎么安装opcachecentos php怎么安装opcacheJan 19, 2023 am 09:50 AM

centos php安装opcache的方法:1、执行“yum list php73* | grep opcache”命令;2、通过“yum install php73-php-opcache.x86_64”安装opcache;3、使用“find / -name opcache.so”查找“opcache.so”的位置并将其移动到php的扩展目录即可。

centos 怎么离线安装 mysqlcentos 怎么离线安装 mysqlFeb 15, 2023 am 09:56 AM

centos离线安装mysql的方法:1、将lib中的所有依赖上传到linux中,并用yum命令进行安装;2、解压MySQL并把文件复制到想要安装的目录;3、修改my.cnf配置文件;4、复制启动脚本到资源目录并修改启动脚本;5、将mysqld服务加入到系统服务里面;6、将mysql客户端配置到环境变量中,并使配置生效即可。

centos 7安装不出现界面怎么办centos 7安装不出现界面怎么办Jan 03, 2023 pm 05:33 PM

centos7安装不出现界面的解决办法:1、选择“Install CentOS 7”,按“e”进入启动引导界面;2、 将“inst.stage2=hd:LABEL=CentOS\x207\x20x86_64”改为“linux dd”;3、重新进入“Install CentOS 7”,按“e”将“hd:”后的字符替换成“/dev/sdd4”,然后按“Ctrl+x”执行即可。

centos 怎么删除 phpcentos 怎么删除 phpFeb 24, 2021 am 09:15 AM

centos删除php的方法:1、通过“#rpm -qa|grep php”命令查看全部php软件包;2、通过“rpm -e”命令卸载相应的依赖项;3、重新使用“php -v”命令查看版本信息即可。

如何在 CentOS 9 Stream 上安装 Nagios如何在 CentOS 9 Stream 上安装 NagiosMay 10, 2023 pm 07:58 PM

我们的PC中有一个磁盘驱动器专门用于所有与Windows操作系统相关的安装。该驱动器通常是C驱动器。如果您还在PC的C盘上安装了最新的Windows11操作系统,那么所有系统更新(很可能是您安装的所有软件)都会将其所有文件存储在C盘中。因此,保持此驱动器没有垃圾文件并在C驱动器中拥有足够的存储空间变得非常重要,因为该驱动器拥有的空间越多,您的Windows11操作系统运行起来就越顺畅。但是您可以在磁盘驱动器上增加多少空间以及可以删除多少文件是有限制的。在这种情况下,

centos中ls命令不显示颜色怎么办centos中ls命令不显示颜色怎么办Apr 20, 2022 pm 03:16 PM

方法:1、利用“vim ~/.bashrc”编辑用户目录(~)下的“.bashrc”文件;2、在文件内添加“alias ls="ls --color"”;3、利用“:wq!”命令保存文件内的更改;4、“exit”命令退出终端后重新连接即可。

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)