【问题标题】:How to compile PHP 5.5.19 with OpenSSL 1.0.1 on OS X如何在 OS X 上使用 OpenSSL 1.0.1 编译 PHP 5.5.19
【发布时间】:2015-01-21 14:54:09
【问题描述】:

我已将 OpenSSL 1.0.1j 安装到 /usr/local/ssl,现在我正在尝试使用此版本的 OpenSSL 编译 PHP 5.5.19。这是我的配置过程...

export CFLAGS="-arch x86_64"
export CXXFLAGS="-arch x86_64"
export LDFLAGS="-L/usr/local/ssl/lib"
export CPPFLAGS="-I/usr/local/ssl/include"
./configure \
--prefix=/usr/local/php5 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--with-config-file-path=/etc \
--with-zlib \
--with-zlib-dir=/usr \
--with-apxs2=/usr/sbin/apxs \
--with-openssl=/usr/local/ssl \
--without-iconv \
--enable-cli \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-sockets \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-mcrypt \
--with-curl

配置过程似乎工作正常,但是当我运行 make 时,我得到了这个:

Undefined symbols for architecture x86_64:
"_PKCS5_PBKDF2_HMAC", referenced from:
_zif_openssl_pbkdf2 in openssl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libs/libphp5.bundle] Error 1

如果我运行相同的配置选项,但将 openssl 指向系统版本 /usr

...
--with-openssl=/usr
...

然后 make 运行没有问题并且 php 安装正常,但使用的是旧版本的 OpenSSL。如何让它使用我较新版本的 OpenSSL?

【问题讨论】:

    标签: php macos openssl undefined symbols


    【解决方案1】:

    Makefile 有一行 EXTRA_LIBS,类似于:

    EXTRA_LIBS = -lresolv -lmcrypt -lltdl -liconv-lm -lxml2 -lcurl  -lssl -lcrypto
    

    删除所有出现的-lssl-lcrypto,并将完整路径添加到libssl.dyliblibcrypto.dylib

    EXTRA_LIBS = -lresolv -lmcrypt /usr/local/ssl/lib/libssl.dylib /usr/local/ssl/lib/libcrypto.dylib -lltdl -liconv-lm -lxml2 -lcurl
    

    【讨论】:

      【解决方案2】:

      两件事,首先,如果你使用 php 和 apache,编译和安装 apr-util 并配置 openssl 可能更重要。但是,如果您只是想让 php 与您的自定义构建 openssl 一起工作,您可以通过以下步骤来完成:

      1) 假设您已经构建并安装了您的 openssl:

      /opt/install2015/openssl-1.0.1p/
      

      2) 设置你的环境变量:

      LD_LIBRARY_PATH=/opt/install2015/openssl-1.0.1p/lib/
      PATH=/opt/install2015/openssl-1.0.1p/bin
      LD_RUN_PATH=/opt/install2015/openssl-1.0.1p/lib
      

      我有两个系统,其中一个仅适用于 PATH 环境变量集。在另一个较旧的系统上,我也需要设置 LD_x 变量才能使其工作。

      3) 你的 php 配置可以是:

      ./configure \
      --with-openssl \
      ...
      

      之后,运行配置脚本,make 和 make install。

      【讨论】:

      • PATH 应设置为:PATH=/opt/install2015/openssl-1.0.1p/bin:$PATH
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 2016-06-04
      • 2016-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多