[英]Install PHP gnupg using PECL on MAC/MAMP 10.8.4
我正在尝试使用PECL在Mac上安装gnupg。
sudo pecl安装gnupg
downloading gnupg-1.3.3.tgz ... Starting to download gnupg-1.3.3.tgz (19,141 bytes) ......done: 19,141 bytes 5 source files, building WARNING: php_bin /Applications/MAMP/bin/php/php5.5.3/bin/php appears to have a suffix /php5.5.3/bin/php, but config variable php_suffix does not match running: phpize Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 building in /private/tmp/pear/install/pear-build-rootj1cVj1/gnupg-1.3.3 running: /private/tmp/pear/install/gnupg/configure checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /opt/local/bin/gsed 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-apple-darwin12.4.0 checking host system type... x86_64-apple-darwin12.4.0 checking target system type... x86_64-apple-darwin12.4.0 checking for PHP prefix... /Applications/MAMP/bin/php/php5.5.3 checking for PHP includes... -I/Applications/MAMP/bin/php/php5.5.3/include/php -I/Applications/MAMP/bin/php/php5.5.3/include/php/main -I/Applications/MAMP/bin/php/php5.5.3/include/php/TSRM -I/Applications/MAMP/bin/php/php5.5.3/include/php/Zend -I/Applications/MAMP/bin/php/php5.5.3/include/php/ext -I/Applications/MAMP/bin/php/php5.5.3/include/php/ext/date/lib checking for PHP extension directory... /Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212 checking for PHP installed headers prefix... /Applications/MAMP/bin/php/php5.5.3/include/php 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 gnupg support... yes, shared checking for gnupg files in default path... not found configure: error: Please reinstall the gpgme distribution ERROR: `/private/tmp/pear/install/gnupg/configure' failed
我已经将问题缩小到安装gpgme的范围,但是我找不到在任何地方进行安装的正确方法。
使用PHP 5.4.24,Mac OSX 10.9.3时,我遇到了同样的问题。 我必须执行以下步骤才能使用PECL安装gnupg(v1.3.3)。
首先,我使用homebrew安装了gnupg
和gpgme
软件包。 Homebrew将软件包安装在/usr/local
。 这是重要的,因为gnupg PECL模块搜索以下位置/usr/local/include /usr/include /usr/local/include/gpgme/ /usr/include/gpgme/
以检测gpgpme
的安装。
其次,我尝试使用PECL安装gnupgp:
pecl install gnupg
在撰写本文时,PECL模块的代码包含两个语句,以防止模块正确编译和链接。 这导致以下错误:
...compile statements...
cc ${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/lib
ld: warning: directory not found for option '-L/usr/local/include/lib'
duplicate symbol _gnupg_keylistiterator_class_entry in:
.libs/gnupg.o
.libs/gnupg_keylistiterator.o
duplicate symbol _gnupg_class_entry in:
.libs/gnupg.o
.libs/gnupg_keylistiterator.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [gnupg.la] Error 1
第三,我必须基于Jim Jagielski的补丁通过手动编辑和安装PECL模块来解决此错误。 这些是我完成的步骤:
下载gnupg-pecl模块:
pecl download gnupg
解压gnupg-pecl模块:
tar xvf gnupg-1.3.3.tgz
更改目录:
cd gnupg-1.3.3
通过更改第49行来修改php_gnupg.h
:
zend_class_entry *gnupg_class_entry;
进入static zend_class_entry *gnupg_class_entry;
通过更改第44行来修改php_gnupg_keylistiterator.h
:
zend_class_entry *gnupg_keylistiterator_class_entry;
进入static zend_class_entry *gnupg_keylistiterator_class_entry;
准备要编译的PHP模块,运行:
phpize
配置模块:
./configure
构建模块:
make
安装模块:
make install
编译后,模块已安装在/Users/USERNAME/tmp/pear/install/gnupg-1.3.3/module
。 因为PHP共享扩展安装在/usr/lib/php/extensions/no-debug-non-zts-20100525/
,所以我复制了模块:
cp /Users/USERNAME/tmp/pear/install/gnupg-1.3.3/modules/gnupg.so /usr/lib/php/extensions/no-debug-non-zts-20100525/
将扩展添加到PHP。 因此,打开/etc/php.ini
并添加以下行:
[gnupg] extension=gnupg.so
通过执行以下行来测试扩展:
php -r "print_r(new gnupg());"
请记住,这是从源代码构建的,因此需要gpgme标头才能编译扩展。 因此,寻找该软件包的开发版本:在Linux中,我遇到了同样的问题,即:gpgme-devel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.