如何在OS X上使用OpenSSL 1.0.1编译PHP 5.5.19

时间:2014-11-23 23:19:06

标签: php macos openssl undefined symbols

我已经将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
...

然后运行没有问题和PHP安装很好,但使用旧版本的OpenSSL。如何才能使用我的新版OpenSSL?

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

两件事,首先,如果你使用带有apache的php,编译和安装配置了openssl的apr-util可能更重要。但是如果你只想让php使用自定义构建openssl,你可以按照以下步骤进行:

1)假设您已在以下位置构建并安装了openssl:

/opt/install2015/openssl-1.0.1p/

2)设置你的env var:

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 env var set。在另一个较旧的系统上,我需要设置LD_x变量以使其工作。

3)你的php配置可以是:

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

之后,运行configure脚本,make和make install。