Home > Backend Development > PHP Problem > How to install php php_mcrypt

How to install php php_mcrypt

PHPz
Release: 2023-04-10 09:50:06
Original
1031 people have browsed it

PHP is a server-side scripting language widely used in web development. Many websites use PHP to perform backend database operations and other services. However, when using PHP for development, encryption and decryption operations are sometimes involved. In this case, you need to install the php_mcrypt extension.

  1. Download mcrypt

Before starting the installation, you need to download mcrypt first. The URL is: http://mcrypt.sourceforge.net/mcrypt.php

Or use the command line to download directly, execute the following command:

wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr
make
make install
Copy after login
  1. Download php_mcrypt source code

After downloading the mcrypt dependent library, you need to download the php_mcrypt extension source code. It can be downloaded from the official website (https://pecl.php.net/package/mcrypt). After downloading, unzip it and enter the folder.

  1. Modify the configuration file

Enter the PHP source code directory, find the php.ini file, and edit it:

vim /usr/local/php/etc/php.ini
Copy after login

Find "Dynamic Extensions", Add the following content below:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/"

extension = mcrypt.so
Copy after login

Note: Please modify the extension_dir here to the PHP extension directory. Please copy and paste the rest of the content directly.

  1. Compile and install

First you need to determine the current PHP version. You can use the following command to query:

php -v
Copy after login

After finding the PHP version, return to the php_mcrypt source code Root directory, execute the following command:

phpize
Copy after login

Compile and install:

./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
Copy after login
  1. Verification

Finally, restart the PHP service and execute the php -m command to view Whether mcrypt is included in the enabled extension.

service php-fpm restart
php -m
Copy after login

If the name of mcrypt is found in the list, the extension is installed successfully.

Summary

Although installing php_mcrypt seems complicated, it can be easily installed as long as you follow the above steps. Only after the php_mcrypt extension is installed can the encryption and decryption functions be used in PHP projects. Therefore, it is recommended that developers who need it must follow the above steps to complete the installation of the extension.

The above is the detailed content of How to install php php_mcrypt. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template