首页 >

PHP安装gpg扩展

后端开发|php教程PHP安装gpg扩展
checking,gnupg,include,Downloads,usr
后端开发-php教程
我看了下,基本上原生php没有安装gpg扩展过。所以我们自己为php安装gpg扩展:
免费图片投票源码,ubuntu的qt开发,如何登陆到tomcat里,scrapy整站爬虫,人员信息登记系统 php,百度seo排名公司seo工资lzw
1.首先我们去下载gpg的源码包:
美食餐饮管理加盟企业织梦源码,ubuntu启动卡grub,淘宝爬虫价格乱码,php递归执行,倾尘土seolzw
http://pecl.php.net/package/gnupg
小京东客户端源码下载,运行vscode硬件要求,ubuntu for phones,查看tomcat启动进程,黑体 爬虫,报销 php,番禺区seo服务,思途cms网站源码,织梦商城源码交易下载站模板lzw
我下载的是:gnupg-1.3.6.tgz

解压之后,cd到目录中phpize,然后./configure。

2.

andy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$ phpizeConfiguring for:PHP Api Version:         20100412Zend Module Api No:      20100525Zend Extension Api No:   220100525andy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$ ./configurechecking for grep that handles long lines and-e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for a sed that does not truncate output... /usr/bin/sedchecking for cc... ccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether cc accepts -g... yeschecking for cc option to accept ISO C89...none neededchecking how to run the C preprocessor... cc -Echecking for icc... nochecking for suncc... nochecking whether cc understands -cand-o together... yeschecking for system library directory... libchecking if compiler supports -R... nochecking if compiler supports -Wl,-rpath,... yeschecking build system type... i386-apple-darwin13.4.0checking host system type... i386-apple-darwin13.4.0checking target system type... i386-apple-darwin13.4.0checking for PHP prefix... /usrchecking for PHP includes...-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/libchecking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20100525checking for PHP installed headers prefix... /usr/include/phpchecking if debug is enabled... nochecking if zts is enabled... nochecking for re2c... noconfigure: WARNING: You will need re2c 0.13.4or later if you want to regenerate PHP parsers.checking for gawk... nochecking for nawk... nochecking for awk... awkchecking if awk is broken... nochecking for gnupg support... yes, sharedchecking for gnupg files in default path...not foundconfigure: error: Please reinstall the gpgme distribution

可以看出来提醒我们安装gpgme。ok,那我们下面安装gpgme。

我们安装gpgme

andy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$ brew install gpgme==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gpgme-1.4.3########################################################################100.0%==> Pouring gpgme-1.4.3.mavericks.bottle.tar.gz??  /usr/local/Cellar/gpgme/1.4.3: 17 files, 1.2Mandy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$ ./configurechecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for a sed that does not truncate output... /usr/bin/sedchecking for cc... ccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether cc accepts -g... yeschecking for cc option to accept ISO C89... none neededchecking how to run the C preprocessor... cc -Echecking for icc... nochecking for suncc... nochecking whether cc understands -c and -o together... yeschecking for system library directory... libchecking if compiler supports -R... nochecking if compiler supports -Wl,-rpath,... yeschecking build system type... i386-apple-darwin13.4.0checking host system type... i386-apple-darwin13.4.0checking target system type... i386-apple-darwin13.4.0checking for PHP prefix... /usrchecking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/libchecking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20100525checking for PHP installed headers prefix... /usr/include/phpchecking if debug is enabled... nochecking if zts is enabled... nochecking for re2c... noconfigure: WARNING: You will need re2c 0.13.4or later if you want to regenerate PHP parsers.checking for gawk... nochecking for nawk... nochecking for awk... awkchecking if awk is broken... nochecking for gnupg support... yes, sharedchecking for gnupg files indefault path... found in /usr/local/includechecking for gpgme_check_version in -lgpgme... yeschecking for gpg... /usr/local/bin/gpgchecking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ldchecking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... nochecking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -rchecking for BSD-compatible nm... /usr/bin/nmchecking whether ln -s works... yeschecking how to recognize dependent libraries... pass_allchecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking dlfcn.h usability... yeschecking dlfcn.h presence... yeschecking for dlfcn.h... yeschecking the maximum length of command line arguments... 196608checking command to parse /usr/bin/nm output from cc object... okchecking for objdir... .libschecking for ar... archecking for ranlib... ranlibchecking for strip... stripchecking for dsymutil... dsymutilchecking for nmedit... nmeditchecking for -single_module linker flag... yeschecking for -exported_symbols_list linker flag... yeschecking if cc supports -fno-rtti -fno-exceptions... yeschecking for cc option to produce PIC... -fno-commonchecking if cc PIC flag -fno-common works... yeschecking if cc static flag -static works... nochecking if cc supports -c -o file.o... yeschecking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yeschecking dynamic linker characteristics... darwin13.4.0 dyldchecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... nocreating libtoolappending configuration tag "CXX" to libtoolconfigure: creating ./config.statusconfig.status: creating config.handy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$

make:

andy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$ make/bin/sh /Users/andy/Downloads/gnupg-1.3.6/libtool --mode=compile cc  -I.-I/Users/andy/Downloads/gnupg-1.3.6-DPHP_ATOM_INC-I/Users/andy/Downloads/gnupg-1.3.6/include -I/Users/andy/Downloads/gnupg-1.3.6/main -I/Users/andy/Downloads/gnupg-1.3.6-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H-g-O2-c /Users/andy/Downloads/gnupg-1.3.6/gnupg.c -o gnupg.lomkdir .libs cc -I.-I/Users/andy/Downloads/gnupg-1.3.6-DPHP_ATOM_INC-I/Users/andy/Downloads/gnupg-1.3.6/include -I/Users/andy/Downloads/gnupg-1.3.6/main -I/Users/andy/Downloads/gnupg-1.3.6-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H-g-O2-c /Users/andy/Downloads/gnupg-1.3.6/gnupg.c  -fno-common-DPIC-o.libs/gnupg.o/bin/sh /Users/andy/Downloads/gnupg-1.3.6/libtool --mode=compile cc  -I.-I/Users/andy/Downloads/gnupg-1.3.6-DPHP_ATOM_INC-I/Users/andy/Downloads/gnupg-1.3.6/include -I/Users/andy/Downloads/gnupg-1.3.6/main -I/Users/andy/Downloads/gnupg-1.3.6-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H-g-O2-c /Users/andy/Downloads/gnupg-1.3.6/gnupg_keylistiterator.c -o gnupg_keylistiterator.lo cc -I.-I/Users/andy/Downloads/gnupg-1.3.6-DPHP_ATOM_INC-I/Users/andy/Downloads/gnupg-1.3.6/include -I/Users/andy/Downloads/gnupg-1.3.6/main -I/Users/andy/Downloads/gnupg-1.3.6-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H-g-O2-c /Users/andy/Downloads/gnupg-1.3.6/gnupg_keylistiterator.c  -fno-common-DPIC-o.libs/gnupg_keylistiterator.o/bin/sh /Users/andy/Downloads/gnupg-1.3.6/libtool --mode=link cc -DPHP_ATOM_INC-I/Users/andy/Downloads/gnupg-1.3.6/include -I/Users/andy/Downloads/gnupg-1.3.6/main -I/Users/andy/Downloads/gnupg-1.3.6-I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H-g-O2-o gnupg.la -export-dynamic-avoid-version-prefer-pic-module-rpath /Users/andy/Downloads/gnupg-1.3.6/modules  gnupg.lo gnupg_keylistiterator.lo -Wl,-rpath,/usr/local/include/lib -L/usr/local/include/lib -lgpgmecc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o.libs/gnupg.so -bundle.libs/gnupg.o .libs/gnupg_keylistiterator.o  -L/usr/local/include/lib -lgpgme-Wl,-rpath-Wl,/usr/local/include/libld: warning: directory not found for option '-L/usr/local/include/lib'dsymutil .libs/gnupg.so || :creating gnupg.la(cd .libs && rm -f gnupg.la && ln -s../gnupg.la gnupg.la)/bin/sh /Users/andy/Downloads/gnupg-1.3.6/libtool --mode=install cp ./gnupg.la /Users/andy/Downloads/gnupg-1.3.6/modulescp ./.libs/gnupg.so /Users/andy/Downloads/gnupg-1.3.6/modules/gnupg.socp ./.libs/gnupg.lai /Users/andy/Downloads/gnupg-1.3.6/modules/gnupg.la----------------------------------------------------------------------Libraries have been installed in:   /Users/andy/Downloads/gnupg-1.3.6/modulesIf you ever happen to want tolink against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify 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 `DYLD_LIBRARY_PATH' environment variable     during executionSee any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.----------------------------------------------------------------------Build complete.Don't forget to run 'make test'.andy@AndyMacBookPro:~/Downloads/gnupg-1.3.6$

4.我们可以看到so文件已经生成,我们把so文件移动到php的扩展目录中:

andy@AndyMacBookPro:/usr/lib/php/extensions/no-debug-non-zts-20100525$ sudo cp /Users/andy/Downloads/gnupg-1.3.6/modules/gnupg.so ./

之后我们到php.ini中添加此扩展:

extension = gnupg.so

之后我们就可以在php中使用gunpg扩展了:

<?php$url = 'http://192.168.2.85/2015/09/20/加密文件.csv';$data = file_get_contents($url);$data = mb_convert_encoding($data, 'UTF-8', 'GBK');$encrypted_text = $data;$res = gnupg_init();gnupg_adddecryptkey($res,"ABCFA237F71C57CA2042439F93704A63BCC8A2F","12345678");$plain = gnupg_decrypt($res,$encrypted_text);var_dump($plain);exit;

非常感谢这篇文章:

http://devzone.zend.com/1278/using-gnupg-with-php/

以上就介绍了PHP安装gpg扩展,包括了方面的内容,希望对PHP教学有兴趣的朋友有所帮助。


PHP安装gpg扩展
  • XP上搭建织梦网站
  • XP上搭建织梦网站 | XP上搭建织梦网站 ...

    PHP安装gpg扩展
  • 小弟想学习php,哪位前辈可以给小弟介绍一下学习php很好的书或者学习视频,该怎么处理
  • 小弟想学习php,哪位前辈可以给小弟介绍一下学习php很好的书或者学习视频,该怎么处理 | 小弟想学习php,哪位前辈可以给小弟介绍一下学习php很好的书或者学习视频,该怎么处理 ...

    PHP安装gpg扩展
  • PHP OPCode缓存 APC详细介绍
  • PHP OPCode缓存 APC详细介绍 | PHP OPCode缓存 APC详细介绍 ...