在MAC/MAMP 10.8.4上使用PECL安装PHP gnupg [英] Install PHP gnupg using PECL on MAC/MAMP 10.8.4

查看:106
本文介绍了在MAC/MAMP 10.8.4上使用PECL安装PHP gnupg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PECL在Mac上安装gnupg.

I am trying to install gnupg on a mac using PECL.

sudo pecl安装gnupg

sudo pecl install 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的范围,但是我找不到在任何地方进行安装的正确方法.

I have narrowed down my problem to getting gpgme installed, but I can't find the correct way to to do it anywhere.

推荐答案

在使用PHP 5.4.24,Mac OSX 10.9.3时,我遇到了同样的问题.我必须执行以下步骤才能使用PECL安装gnupg(v1.3.3).

I was facing the same problem, when using PHP 5.4.24, Mac OSX 10.9.3. I had to take the following steps to install gnupg (v1.3.3) using PECL.

首先,我使用 homebrew 安装了软件包gnupggpgme. Homebrew将软件包安装在/usr/local中.这是导入的,因为gnupg PECL模块搜索以下位置/usr/local/include /usr/include /usr/local/include/gpgme/ /usr/include/gpgme/以检测gpgpme的安装.

Firstly, I installed the software packages gnupg and gpgme using homebrew. Homebrew installs your packages in /usr/local. This is import because the gnupg PECL module searches the following locations /usr/local/include /usr/include /usr/local/include/gpgme/ /usr/include/gpgme/ to detect an installation of gpgpme.

其次,我尝试使用PECL安装gnupgp:

Secondly, I tried to install gnupgp using PECL:

pecl install gnupg

在编写时,PECL模块的代码包含两个语句,这些语句阻止模块正确编译和链接.这导致了以下错误:

At time writing, the code of the PECL module contains two statement that prevents the module from being compiled and linked correctly. This resulted into the following error:

...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的补丁程序.这些是我完成的步骤:

Thirdly, I had to resolve this error by editing and installing the PECL module by hand, based on Jim Jagielski's patch. These are the steps I completed:

  1. 下载gnupg-pecl模块:

  1. Download the gnupg-pecl module:

pecl download gnupg

  • 解压gnupg-pecl模块:

  • Unpack the gnupg-pecl module:

    tar xvf gnupg-1.3.3.tgz
    

  • 更改目录:

  • Change directory:

    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:

    Modify php_gnupg_keylistiterator.h by changing line 44:

    zend_class_entry *gnupg_keylistiterator_class_entry;转换为static zend_class_entry *gnupg_keylistiterator_class_entry;

    对于gnupg-1.4.0或更高版本,不需要执行第4步和第5步.

    Step 4 and 5 are not required on gnupg-1.4.0 or greater.

    1. 准备要编译的PHP模块,运行:

    1. Prepare the PHP module for compiling, run:

    phpize
    

  • 配置模块:

  • Configure the module:

    ./configure
    

  • 构建模块:

  • Build the module:

    make
    

  • 安装模块:

  • Install the module:

    make install 
    

  • 编译后,模块已安装在/Users/USERNAME/tmp/pear/install/gnupg-1.3.3/module中.因为PHP共享扩展安装在/usr/lib/php/extensions/no-debug-non-zts-20100525/中,所以我复制了模块:

  • After compiling the module was installed in /Users/USERNAME/tmp/pear/install/gnupg-1.3.3/module. Because the PHP shared extensions are installed in /usr/lib/php/extensions/no-debug-non-zts-20100525/, I copied the module:

     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并添加以下行:

  • Add the extension to PHP. Therefore open /etc/php.ini and add the following lines:

     [gnupg]
     extension=gnupg.so
    

  • 通过执行以下行来测试扩展:

  • Test the extension, by executing the following line:

     php -r "print_r(new gnupg());"
    

  • 这篇关于在MAC/MAMP 10.8.4上使用PECL安装PHP gnupg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆