mcrypt 是php里面重要的加密支持擴展庫,linux環境下該庫在默認情況下不開啟。window環境下,PHP>=5.3,默認開啟mcrypt擴展。mcrypt擴展是mcrypt加密庫的接口。這個擴展對於允許使用mcrypt的PHP代碼在PHP 7.2+上運行非常有用。
mcrypt擴展的主要問題是,它是基於libmcrypt的,自2007年開始就沒有開發過。因此,即使libmcrypt還在使用,但是由於缺乏適當的開發和維護,庫的安全問題已經成為許多系統管理員關注的焦點。
由於mcrypt擴展開發的結束,擴展也從PHP 7.2中刪除,並轉移到一個非官方的PECL存儲庫中。但是,你仍然可以在PHP 5.4到PHP 7.1中找到mcrypt擴展。PHP 7.2已經發布,但是它不包含mcrypt擴展。對於PHP 7.2+, PHP使用libsodium作為加密庫。
1 |
sudo apt-get -y install gcc make autoconf libc-dev pkg-config |
當你看到提示時
1 | libmcrypt prefix? [autodetect] : |
按[Enter]自動檢測。
安裝mcrypt trought pecl成功后,你應該將mcrypt.so擴展名添加到php.ini中。
輸出將如下所示:
1 |
... Build process completed successfully Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib install ok: channel://pecl.php.net/mcrypt-1.0.1 configuration option "php_ini" is not set to php.ini location You should add "extension=mcrypt.so" to php.ini |
獲取安裝路徑並添加到cli和apache2 php.ini配置中。
1 2 3 4 5 6 7 |
/etc/php/7.2/cli/conf.d/mcrypt.ini Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, convert.iconv.*, mcrypt.*, mdecrypt.* mcrypt mcrypt support => enabled mcrypt_filter support => enabled mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value |
轉載:https://www.php.cn/php-weizijiaocheng-416575.html
總結:php7安裝memcache擴展也可參照該安裝方式