Table of Contents
(1)、确认你的linux没有安装mcrypt库,如果已安装,跳过安装步骤
(方法一)yum命令懒人安装
(方法二)源码编译安装,去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 
(3) 、重启apache,查阅phpinfo,mcrypt模块扩展是不是加载了
Home Backend Development PHP Tutorial PHP之--CentOS下php安装mcrypt扩展(插曲)

PHP之--CentOS下php安装mcrypt扩展(插曲)

Jun 23, 2016 pm 01:33 PM

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

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

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

[root@test-206 ~]# yum list installed|grep mcryptlibmcrypt.x86_64                          2.5.8-4.el5.centos           installedlibmcrypt-devel.x86_64                    2.5.8-4.el5.centos           installedmcrypt.x86_64                             2.6.8-1.el5                  installed
Copy after login

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

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

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

Dependencies Resolved================================================================================ Package              Arch        Version                   Repository     Size================================================================================Installing: libmcrypt            i386        2.5.7-5.el5               epel          124 k libmcrypt            x86_64      2.5.8-4.el5.centos        extras        105 k libmcrypt-devel      i386        2.5.7-5.el5               epel          103 k libmcrypt-devel      x86_64      2.5.8-4.el5.centos        extras         10 k mcrypt               x86_64      2.6.8-1.el5               epel           88 k mhash                i386        0.9.2-6.el5               epel          141 k mhash                x86_64      0.9.9-1.el5.rf            rpmforge      161 kTransaction Summary================================================================================Install       7 Package(s)Upgrade       0 Package(s)Total download size: 731 kIs this ok [y/N]:
Copy after login
Installed:  libmcrypt.x86_64 0:2.5.8-4.el5.centos  libmcrypt-devel.x86_64 0:2.5.8-4.el5.centos  mcrypt.x86_64 0:2.6.8-1.el5  mhash.x86_64 0:0.9.9-1.el5.rfComplete!
Copy after login

(方法二)源码编译安装,去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 ):

1.先安装Libmcrypt

#tar -zxvf libmcrypt-2.5.8.tar.gz#cd libmcrypt-2.5.8#./configure#make#make install 说明:libmcript默认安装在/usr/local
Copy after login

2.安装mhash

#tar -zxvf mhash-0.9.9.9.tar.gz#cd mhash-0.9.9.9#./configure#make#make install
Copy after login

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
Copy after login

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

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

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

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

进入ext/mcrypt文件夹

[root@*_* 14:45 ~]# cd php-5.3.3/ext/mcrypt/
Copy after login
执行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]# phpizeConfiguring for:PHP Api Version:         20090626Zend Module Api No:      20090626Zend Extension Api No:   220090626
Copy after login

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

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

[root@*_* 15:02 mcrypt]# whereis php-configphp-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
Copy after login
如果遇到以下错误,请先安装gcc,命令yum install gcc
configure: error: no acceptable C compiler found in $PATH
Copy after login
直到不报错,出现:config.status: creating config.h,执行以下命令
[root@*_* 15:06 mcrypt]# make && make install
Copy after login
最后的最后,会提示你如下,说明你大功告成了

Installing shared extensions:     /usr/lib64/php/modules/
Copy after login

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

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

[root@*_* 15:09 mcrypt]# cd /etc/php.d
Copy after login
创建一个mrcypt.ini文件就行,里面写extension=mcrypt.so

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

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










Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles