How do I install PHP with openssl on Mac High Sierra? - php

I'm using Mac High Sierra. I want to install PHP 7.2 with the openssl extension. I have openssl installed
localhost:php-7.2.1 davea$ brew install openssl
Warning: openssl 1.0.2n is already installed
However, when I run the PHP configure command (I'm building it from source), it eventually dies with the below error
localhost:php-7.2.1 davea$ ./configure --with-gmp=/usr/local --with-openssl --with-openssl-dir=/opt/local/bin
...
checking for Kerberos support... no
checking whether to use system default cipher list instead of hardcoded value... no
checking for RAND_egd... no
checking for pkg-config... /usr/local/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
How do I tell PHP where that library is or rather how do I install it somewhere on my Mac?
ps - The reason I'm not installing PHP with homebrew is because homebrew does not support installation of PHP with GMP, which I need.

Related

pecl install memcached - Can't find ZLIB headers under "/opt/homebrew/opt/zlib/include"

I have installed PHP, zlib and memcached using Homebrew on a Mac with Apple silicon. I am trying to install the memcached extension for PHP using
sudo pecl install memcached
When it prompts me for zlib directory [no] : I specified "/opt/homebrew/opt/zlib/include"
I have confirmed that this directory contains the files zlib.h and zconf.h. brew info zlib also tells me
For compilers to find zlib you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"
For pkg-config to find zlib you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig"
So I seem to be supplying the correct path for zlib. However, running sudo pecl install memcached is throwing the following error:
checking whether to use system FastLZ library... no
checking for ZLIB... yes, shared
checking for pkg-config... /opt/homebrew/bin/pkg-config
configure: error: Can't find ZLIB headers under "/opt/homebrew/opt/zlib/include"
ERROR: `/private/tmp/pear/temp/memcached/configure --with-php-config=/opt/homebrew/opt/php/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=/opt/homebrew/opt/zlib/include --with-system-fastlz=no --enable-memcached-igbinary=no --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=no --enable-memcached-session=no' failed
How do I fix this?

How to install PHP extension using PECL (with Homebrew)

I try to install amqp php extension on my mac using brew.
Enviroment: MacOS Catalina 10.15.6,
Homebrew 2.5.0, PHP 7.4.10, rabbitmq 3.8.8, rabbitmq-c 0.10.0
I got following messages after executing: pecl install amqp
checking for pkg-config... /usr/local/bin/pkg-config
checking for amqp using pkg-config... configure: error: librabbitmq not found
ERROR: `/private/tmp/pear/temp/amqp/configure --with-php-config=/usr/local/opt/php/bin/php-config --with-librabbitmq-dir' failed
Any ideas how to solve this problem.
For anyone with similar problem.
For the question:
Set the path to librabbitmq install prefix [autodetect] :
do not leave empty answer (autodetect).
In my case, setting this value to
/usr/local/Cellar/rabbitmq-c/0.10.0
do the job.

How to overcome the "dyld: Library not loaded:" error when installing PHP on Mac?

I'm trying to install the latest version of PHP on my Mac. I tried this
brew install php72 --force
and then wanted to check the version, but got this error
localhost:regagents davea$ php --version
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
Referenced from: /usr/local/Cellar/php72/7.2.1_12/bin/php
Reason: image not found
Abort trap: 6
so I figured I could re-install readline, so I think I did ...
localhost:regagents davea$ brew reinstall readline
==> Reinstalling readline
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.0.high_sierra.bottle.tar.gz
Already downloaded: /Users/davea/Library/Caches/Homebrew/downloads/c0566e677ba9f92c270590e2d8132f95668817a7817d2ee47711ff3c2ff045d6--readline-8.0.0.high_sierra.bottle.tar.gz
==> Pouring readline-8.0.0.high_sierra.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
For compilers to find readline you may need to set:
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
For pkg-config to find readline you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
==> Summary
🍺 /usr/local/Cellar/readline/8.0.0: 48 files, 1.5MB
but then running "php -version" gives me the same error. What gives? How do I install and run php on my Mac?
Your older version of php is linked against readline 7. You have readline 8. Update php: the latest version of the php72 package in homebrew is 7.2.17_1.
brew update
brew upgrade php72
php 7.3.4 is available from the php package. To install the latest version of php:
brew install php

How to compile PHP with new OpenSSL library

I am trying to compile PHP with OpenSSL. That works with the default OpenSSL library 0.9.6 by simply configuring with --with-openssl=/usr.
However, I have installed a new OpenSSL library 1.0.0 which I would like to compile PHP with. This library lives in /usr/local/ssl/bin.
That unfortunately does not work:
configure: error: Cannot find OpenSSL's <evp.h>
How can I compile PHP with the new OpenSSL library?
fixed it by recompiling curl as the compiled version of curl was also using the old openssl lib
sudo ./configure -disable-shared -with-ssl=/usr/local/ssl
After compiling curl, also compiled php again --with-openssl=/usr and phpinfo tells me it is using the new openssl lib.
I had the same problem, but before compiling (./configure -disable-shared -with-ssl=/usr/local/ssl) I removed (yum openssl-devel) and it worked
For those using MacPorts adding ssl is super simple:
$ sudo port install php71-openssl
That's it. Ports will recompile php (version 7.1 in this case) with openssl for you.

please re-compile PHP with ZTS enabled Mac OS X

I trying to install pthreads on Mac Os X.
When I execute:
sudo pecl install pthreads
I get error:
checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
ERROR: `/private/tmp/pear/temp/pthreads/configure' failed
So the question is how to recompile php with ZTS enabled for OS X?
I suggest you don't recompile OS X native php. Instead build and install new thread-safe version to different location.
If you use homebrew you should install it with -with-thread-safety option.
If you prefer to build it manually add --enable-maintainer-zts option to configure script.
Sadly Homebrew is not supporting the thread-safe version anymore: https://github.com/Homebrew/homebrew-core/blob/master/Formula/php.rb#L56

Categories