How to compile PHP with OpenSSL on OS X 10.9?

I am trying to compile PHP 5.6.10 from the source, and I ran into the following problem:

Undefined symbols for architecture x86_64: "_PKCS5_PBKDF2_HMAC", referenced from: _zif_openssl_pbkdf2 in openssl.o "_TLSv1_1_client_method", referenced from: _php_openssl_setup_crypto in xp_ssl.o "_TLSv1_1_server_method", referenced from: _php_openssl_setup_crypto in xp_ssl.o "_TLSv1_2_client_method", referenced from: _php_openssl_setup_crypto in xp_ssl.o "_TLSv1_2_server_method", referenced from: _php_openssl_setup_crypto in xp_ssl.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 is installed through Brew. Included in PHP as --with-openssl=/usr/local/Cellar/openssl/1.0.2c

PS Before trying to use only /usr for OpenSSL, but got the same error.

+7
php homebrew openssl osx-mavericks
source share
3 answers

There is a line in the Makefile with EXTRA_LIBS , something like:

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

Remove all occurrences of -lssl and -lcrypto and add the full path to libssl.dylib and libcrypto.dylib (brew openssl links in / usr / local / opt / openssl / lib /)

 EXTRA_LIBS = -lresolv -lmcrypt /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib -lltdl -liconv-lm -lxml2 -lcurl 
+8
source share

To follow Bob Fanger's answer (which worked fine for me on os x 10.11.3), here is a little script you can run from within the build directory, due to which the Makefile changes:

 #!/usr/bin/php <?php if (true != copy('Makefile', 'Makefile.sav')) die("** cannot copy 'Makefile' to 'Makefile.sav'\n"); $lines = file('Makefile'); if (false == $lines) die("** connot read 'Makefile'\n"); $output = fopen('Makefile', 'wb'); if (false == $output) die("** unable to open 'Makefile'\n"); foreach ($lines as $line) { if (preg_match('/^EXTRA_LIBS\s+=\s+/', $line)) { $line = preg_replace('/^EXTRA_LIBS\s+=\s+/', 'EXTRA_LIBS = /usr/local/opt/openssl/lib/libssl.dylib /usr/local/opt/openssl/lib/libcrypto.dylib', $line); $line = preg_replace(['/-lssl/', '/-lcrypto/'], [], $line); } if (false === fwrite($output, $line)) die("** writing line to 'Makefile' failed\n"); } fclose($output); echo "Success - your Makefile is set for ssl\n"; 

Enjoy it!

+2
source share

If you use phpbrew on OSX El Capitan, you need to provide the full path to your opensl:

phpbrew install php-7.0.4 +openssl=/usr/local/Cellar/openssl/[YOUR OPEN SSL VERSION]

0
source share

All Articles