ubuntu 18.04 安装 php7.2-mcrypt

检查版本,安装pecl支持

php -v  # 检查版本,确定为php7.2
pecl version
sudo apt-get install php-pear
sudo apt-get install php7.2-dev

安装 mcrypt extension

mcrypt支持查看 http://pecl.php.net/package-info.php?package=mcrypt&version=1.0.1

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1

输出以下信息,直接回车就行

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading mcrypt-1.0.1.tgz ...
Starting to download mcrypt-1.0.1.tgz (33,782 bytes)
.........done: 33,782 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
libmcrypt prefix? [autodetect] :
building in /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1
running: /tmp/pear/temp/mcrypt/configure --with-php-config=/usr/bin/php-config --with-mcrypt
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20170718
checking for PHP installed headers prefix... /usr/include/php/20170718
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for mcrypt support... yes, shared
checking for libmcrypt version... >= 2.5.6
checking for mcrypt_module_open in -lmcrypt... yes
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/x86_64-linux-gnu-ld
checking if the linker (/usr/bin/x86_64-linux-gnu-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/x86_64-linux-gnu-ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/x86_64-linux-gnu-ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/bash /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/mcrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/include -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/main -I/tmp/pear/temp/mcrypt -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/mcrypt/mcrypt.c -o mcrypt.lo
libtool: compile:  cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/mcrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/include -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/main -I/tmp/pear/temp/mcrypt -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/mcrypt/mcrypt.c  -fPIC -DPIC -o .libs/mcrypt.o
/bin/bash /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/mcrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/include -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/main -I/tmp/pear/temp/mcrypt -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/mcrypt/mcrypt_filter.c -o mcrypt_filter.lo
libtool: compile:  cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/mcrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/include -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/main -I/tmp/pear/temp/mcrypt -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/mcrypt/mcrypt_filter.c  -fPIC -DPIC -o .libs/mcrypt_filter.o
/bin/bash /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/libtool --mode=link cc -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/include -I/tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/main -I/tmp/pear/temp/mcrypt -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o mcrypt.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules  mcrypt.lo mcrypt_filter.lo -lmcrypt -lltdl
libtool: link: cc -shared  -fPIC -DPIC  .libs/mcrypt.o .libs/mcrypt_filter.o   /usr/lib/libmcrypt.so /usr/lib/x86_64-linux-gnu/libltdl.so  -g -O2   -Wl,-soname -Wl,mcrypt.so -o .libs/mcrypt.so
libtool: link: ( cd ".libs" && rm -f "mcrypt.la" && ln -s "../mcrypt.la" "mcrypt.la" )
/bin/bash /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/libtool --mode=install cp ./mcrypt.la /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules
libtool: install: cp ./.libs/mcrypt.so /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules/mcrypt.so
libtool: install: cp ./.libs/mcrypt.lai /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules/mcrypt.la
libtool: finish: PATH="/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /tmp/pear/temp/pear-build-rooteTY7Qo/mcrypt-1.0.1/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1" install
Installing shared extensions:     /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr/lib/php/20170718/
running: find "/tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1" | xargs ls -dils
786579   4 drwxr-xr-x 3 root root   4096 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1
786603   4 drwxr-xr-x 3 root root   4096 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr
786604   4 drwxr-xr-x 3 root root   4096 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr/lib
786605   4 drwxr-xr-x 3 root root   4096 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr/lib/php
786606   4 drwxr-xr-x 2 root root   4096 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr/lib/php/20170718
786601 188 -rwxr-xr-x 1 root root 189056 Jul  6 09:35 /tmp/pear/temp/pear-build-rooteTY7Qo/install-mcrypt-1.0.1/usr/lib/php/20170718/mcrypt.so

Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so'
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

添加扩展信息

sudo nano /etc/php/7.2/mods-available/20-mcrypt.ini
添加内容:extension=mcrypt.so
然后连接到conf.d
sudo ln -s /etc/php/7.2/mods-available/20-mcrypt.ini /etc/php/7.2/cli/conf.d/

检查扩展

php -i | grep mcrypt

输出以下信息代表OK

/etc/php/7.2/cli/conf.d/20-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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,378评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,356评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,702评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,259评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,263评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,036评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,349评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,979评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,469评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,938评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,059评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,703评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,257评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,262评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,485评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,501评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,792评论 2 345

推荐阅读更多精彩内容

  • 5月5日是属于助产士的节日,在西方对于助产士是这么定义的,它说:在每个新生命降临的时候,因为上帝不能一一亲临,所...
    love_竹林深处阅读 94评论 0 0
  • 刚刚和女儿通电话,她告诉我说前几天回爷爷奶奶家,带了木心的《文学回忆录》在看,觉得写得很好。她认为木心的文章句式使...
    EmmaLT阅读 260评论 2 0
  • 太阳下山了 留下依旧炙热的大地 知了息声了 树叶依旧一动不动 路灯亮起了 你 依旧看着川流不息的车流 疲惫的身体里...
    雨石_51c1阅读 186评论 0 0
  • 要点 著名培训师杜葵在“北京听道讲坛”做了场演讲,“听”是听见的听,“道”是道理的道。杜葵在演讲中总结了三个和学习...
    川行天下阅读 274评论 0 0