Home Backend Development PHP Tutorial 浅析PHP安装扩展mcrypt以及相关依赖项(PHP安装PECL扩展的方法)_php技巧

浅析PHP安装扩展mcrypt以及相关依赖项(PHP安装PECL扩展的方法)_php技巧

May 17, 2016 am 08:56 AM
mcrypt php

一:Mcrypt简介
Mcrypt是PHP的一个扩展,完成了常用加密算法的封装。其实该扩展是对mcrypt标准类库的封装,mcrypt完成了相当多的常用加密算法,如DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 和 GOST加密算法,并且提供了CBC、OFB、CFB 和 ECB 四种块加密的模型。

二:安装libmcrypt依赖库
要使用该扩展,必须首先安装mcrypt标准类库,注意的是mcrypt软件依赖libmcrypt和mhash两个库。

1.下载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
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install
说明:libmcript默认安装在/usr/local
安装完后重启机器

3.再安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install

4.最后安装mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make
#make install
说明:由于在配置Mcrypt时,会找不到libmcrypt的链接库,导致无法编译,因为Libmcrypt的链接库在/usr/local/lib文件夹下。
因次,在配置mcrypt时要加入LD_LIBRARY_PATH=/usr/local/lib导入键接库。

三.安装PHP的Pecl扩展mcrypt
注意mcrypt是PHP自带的Pecl扩展,所以只要去PHP的解压缩目录去找mcrypt包即可。


1.动态加载
使用php的常见问题是:编译php时忘记添加某扩展,后来想添加扩展,但是因为安装php后又装了一些东西如PEAR等,不想重装整个PHP,于是可以采用动态编译,使用phpize。需要注意的是要有与现有php完全相同的php压缩包。
#cd /usr/php-5.4.8/ext/mcrypt
#/usr/local/webserver/php/bin/phpize
#./configure --with-php-config=/usr/local/webserver/php/bin/php-config
#make && make install
给你的php.ini添加一条extension=mcrypt.so

重启apache
# /usr/local/apache2/bin/apachectl restart
查看phpinfo(),mcrypt以及安装好
安装完成
--------------------------
2.静态编译
在任意PHP文件中加入函数 phpinfo(),即可取得目前PHP的配置
在这些配置后面新增需要加入的配置:--with-mcrypt --with-mhash
然后进入php源代码目录make clean(一定需要) ,然后执行这条完整的configure命令,依次

make
make install
根据你的需要加上所要的配置,例如:
./configure --with-apxs2=/usr/local/web/apache/bin/apxs --with-mcrypt --with-mhash
//./configure --with-apxs2=/usr/local/web/apache/bin/apxs --with-mcrypt --with-mhash --with-libxml-dir --enable-bcmath --enable-sockets
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
4 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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles