I'm using MacOS X 10.7.5 and I need a newer OpenSSL version due to handshake failures. There are several tutorials on the internet and I tried the following:
brew install openssl
brew link openssl --force
Nevertheless, it does not work:
openssl version
OpenSSL 0.9.8r 8 Feb 2011
brew unlink openssl && brew link openssl --force
Unlinking /usr/local/Cellar/openssl/1.0.1e... 1139 links removed
Linking /usr/local/Cellar/openssl/1.0.1e... 1139 symlinks created
The SVN issue is not resolved either. Any ideas? I would rather not try the MacPorts way because it may interfere with Homebrew.
If you're using Homebrew /usr/local/bin should already be at the front of $PATH or at least come before /usr/bin. If you now run brew link --force openssl in your terminal window, open a new one and run which openssl in it. It should now show openssl under /usr/local/bin.
In a terminal, run:
export PATH=/usr/local/bin:$PATH
brew link --force openssl
You may have to unlink openssl first if you get a warning: brew unlink openssl
This ensures we're linking the correct openssl for this situation. (and doesn't mess with .profile)
Hat tip to #Olaf's answer and #Felipe's comment. Some people - such as myself - may have some pretty messed up PATH vars.
installed openssl on mac with brew but nothing found on /usr/local/bin where other brew installed bins are located. Found my fresh openssl here:
/usr/local/opt/openssl/bin/openssl
Run it like this:
/usr/local/opt/openssl/bin/openssl version
I don't want to update OS X openssl, while some OS stuff or other 3rd party apps may have dependency on older version.
I also don't mind longer path than just openssl
Writing this here for all the Googlers who are looking for location of openssl installed by brew.
I had this issue and found that the installation of the newer openssl did actually work, but my PATH was setup incorrectly for it -- my $PATH had the ports path placed before my brew path so it always found the older version of openssl.
The fix for me was to put the path to brew (/usr/local/bin) at the front of my $PATH.
To find out where you're loading openssl from, run which openssl and note the output. It will be the location of the version your system is using when you run openssl. Its going to be somewhere other than the brewpath of "/usr/local/bin". Change your $PATH, close that terminal tab and open a new one, and run which openssl. You should see a different path now, probably under /usr/local/bin. Now run openssl version and you should see the new version you installed "OpenSSL 1.0.1e 11 Feb 2013".
To answer your question regarding updating openssl I followed these steps to successfully update the version found on my Mac to the newest openssl version 1.0.1e.
I followed the steps found here: http://foodpicky.com/?p=99
When you reach the steps for terminal commands make and make install be sure to use sudo make and sudo make install (I had to go through the step-by-step twice because I did it without sudo and it did not update).
Hope this helps
I had problems installing some Wordpress plugins on my local server running php56 on OSX10.11. They failed connection on the external API over SSL.
Installing openSSL didn't solved my problem. But then I figured out that CURL also needed to be reinstalled.
This solved my problem using Homebrew.
brew rm curl && brew install curl --with-openssl
brew uninstall php56 && brew install php56 --with-homebrew-curl --with-openssl
On mac OS X Yosemite, after installing it with brew it put it into
/usr/local/opt/openssl/bin/openssl
But kept getting an error "Linking keg-only openssl means you may end up linking against the insecure" when trying to link it
So I just linked it by supplying the full path like so
ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl
So now when I do
$ openssl version -a
It's showing version OpenSSL 1.0.2o.
So I guess it worked!
Try:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Afterwards try:
brew install homebrew/portable-ruby/portable-openssl
On OSX Big Sur, I had a very frustrating experience with the error, because all of the solutions lean on using brew install. But running brew install was always returning an error like:
Error:
homebrew-core is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
But I couldn't run that command because git was failing with:
% git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/libexec/git-core/git-remote-https
Reason: image not found
In the end, the solution was to reinstall git.
brew reinstall git
And then update symlinks, if necessary:
brew link --overwrite git
For those, who are using macOS Monterey and are installing latest openssl v3 with brew, it's located in completely different path:
/opt/homebrew/Cellar/openssl#3/
A specific version is installed in the subfolder and the binary is reachable at (example for v.3.0.7):
/opt/homebrew/Cellar/openssl#3/3.0.7/bin/openssl
Using brew link --force openssl is still valid to create symlinks. Though it creates symlinks, the system openssl installed in /usr/bin/openssl has a preference because it's located earlier in the $PATH list.
So the solution will be to set the local symlink:
ln -s /opt/homebrew/Cellar/openssl#3/3.0.7/bin/openssl /usr/local/bin/openssl
This preserves 2 version in different path but /usr/local/bin has the highest priority when searching in $PATH.
The drawback is that you'll need to update a symlink once a new version updated with brew because each version is located in a separate subfolder now.
install port: https://guide.macports.org/
install or upgrade openssl package: sudo port install openssl or sudo port upgrade openssl
that's it, run openssl version to see the result.
Related
I have multiple versions of PHP installed on my localhost using homebrew:
the standard core php package (v7.3.12)
php 5.6 from exolnet/homebrew-deprecated
Now when I upgraded php to 7.3.12 recently it upgraded a dependency that php#5.6 requires and now I am getting this error:
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /usr/local/Cellar/php#5.6/5.6.40/bin/./php
Reason: image not found
[1] 83775 abort ./php
And when I navigate to /usr/local/opt/openssl/lib/ I see that I now have the upgraded libcrypto.1.1.dylib installed.
I've tried brew upgrade and reinstalling php#5.6 but no joy.
Does anyone have a suggestion? I really need both versions of php working on my localhost to continue development.
From my experience, trying to manage multiple PHP versions via homebrew is an absolute PITA, and I don't think I've ever got to the point where I can easily have both versions available side by side (until now!). Extensions are also supported, the details of which are provided later on in this answer.
That said, I have found a guide that gives some instructions on how to get this working and it works an absolute treat:
The linked guide references this method in the context of running PHP within Apache, so if that's your use case that's a nice little bonus for you too.
Now, because just posting links as answers on StackOverflow just isn't the done thing, I've detailed the main steps you need to follow in order below. Homebrew uses different paths on Apple Silicon hardware vs Intel because of course it does, so if I've missed any path changes please let me know so I can update my answer.
For anyone following this guide that doesn't yet have the prerequisites installed, ensure you have the Xcode command line tools and Homebrew installed and up to date.
If you want to check Homebrew for any issues, you can run
brew doctor
It's also never a bad idea to ensure that you have OpenSSL installed, especially if starting a fresh on macOS Monterey:
brew install openssl
So, let's get started.
Reset your environment
First, update everything then upgrade:
brew update
brew upgrade
brew cleanup
The reason for this is: "This will actually 'migrate' the core PHP packages (which are the only ones supported), but there's a bunch of symlinks utilized that could cause problems down the road, so after upgrading, we'll remove all PHP packages, to provide a fresh start"
Once you've done that, check what's actually installed:
brew list | grep php
Then remove whatever you find, for example:
brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug
brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug
brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug
brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug
brew cleanup
Double check there's nothing left:
brew list | grep php
and clean up any old configuration files:
Intel:
rm -Rf /usr/local/etc/php/*
Apple Silicon:
rm -Rf /opt/homebrew/etc/php/*
If have the exolnet/deprecated tap installed, you'll need to remove it first using
brew untap exolnet/deprecated
If you don't, you can get some weird conflicts
Add the new Tap and Install
We're then going to tap a different repository. This repository has many versions of PHP pre-built which may or may not work for you, however installation should be much faster as we don't have to compile from source.
brew tap shivammathur/php
You can then install any PHP versions you require:
brew install shivammathur/php/php#7.0
brew install shivammathur/php/php#7.1
brew install shivammathur/php/php#7.2
brew install shivammathur/php/php#7.3
brew install shivammathur/php/php#7.4
brew install shivammathur/php/php#8.0
At the time of writing, this repository has versions 5.6 through 8.1 available for installation
The php.ini files are located in the following directories:
Intel:
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
/usr/local/etc/php/7.2/php.ini
/usr/local/etc/php/7.3/php.ini
/usr/local/etc/php/7.4/php.ini
/usr/local/etc/php/8.0/php.ini
Apple Silicon:
/opt/homebrew/etc/php/7.0/php.ini
/opt/homebrew/etc/php/7.1/php.ini
/opt/homebrew/etc/php/7.2/php.ini
/opt/homebrew/etc/php/7.3/php.ini
/opt/homebrew/etc/php/7.4/php.ini
/opt/homebrew/etc/php/8.0/php.ini
Link your desired version
Once you've got here, close and reopen any terminal windows you have open to avoid strange path issues.
Now, these versions are installed, but not linked. To switch to PHP 7.3 for example, run the following command:
brew unlink php && brew link --overwrite --force php#7.3
And then check we have the correct version:
php -v
If we want to switch to PHP 7.4:
brew unlink php && brew link --overwrite --force php#7.4
And then check we have the correct version:
php -v
Easier Switching
If you want a faster way of switching PHP versions, check out the sPHP script from rhukster
You can install this by running:
Intel:
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/adc8c149876bff14a33e3ac351588fdbe8172c07/sphp.sh > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
Apple Silicon:
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/adc8c149876bff14a33e3ac351588fdbe8172c07/sphp.sh > /opt/homebrew/bin/sphp
chmod +x /opt/homebrew/bin/sphp
and execute it using:
sphp 8.0
Of course, with anything like this YMMV, but this should hopefully be a good starting point and actually get you where you need to be and remove some headaches.
What about extensions?
Well I'm glad you asked. For the later versions, pecl does work. However, if you want to install xdebug for 5.6 for example, pecl throws its toys out of its pram.
There is another repository you can tap, specifically for extensions:
brew tap shivammathur/extensions
Once you've done this, it's as simple as running:
brew install xdebug#5.6
brew install xdebug#8.1
The list of available extensions is detailed in the link above. I won't include them here because it's a dynamic list and it'll soon be out of date, but most of them support 5.6 through to 8.1
Wrap up
Having followed this process myself, this is the easiest approach I'm yet to find for managing multiple PHP versions on macOS. Feel free to run brew doctor and brew cleanup at any points during the process, it can't hurt after all and might in fact help with debugging any issues you happen across. That said, my environment was an absolute mess and this tidied it up in about ten minutes. The longest step in this process for me was updating Homebrew itself.
I installed ruby on my Mac OSX High Sierra and am running into issues now with my php installation for some reason. I'm on php 7.1.
Following this (also here) Github suggestion, I tried
brew update && brew reinstall php71
While installing, it broke at
==> Pouring php#7.1-7.1.23.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/php#7.1/7.1.23/bin/pear config-set php_ini /usr/local/etc/php/7.1/php.ini system
With error:
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/Cellar/php#7.1/7.1.23/bin/php
Reason: image not found
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php#7.1`
Typing in php into terminal throws the same error.
Other things I've tried:
I thought perhaps it wasn't linked, so I also tried: brew unlink libldap && brew link libldap - but libldap is not supported by Homebrew
Then here, while unrelated to postgres, it does discuss the issue of libldap and says to install via brew install openldap (I guess libldap is referred to as openldap to Homebrew) - this installed fine but didn't resolve the issue
How can I fix this?
According to this issue, you need to install openldap and libiconv.
brew install openldap libiconv
I tried it and it worked for my system. I was originally missing the PHP intl extension.
It's worked for me:
brew reinstall openldap
Although I'm not sure why installing Ruby caused the issue, I solved the issue ultimately with:
According to this discussion, libldap is referred to as openldap to Homebrew. brew install openldap then ran php reinstall php71. This linked the libraries properly
The next issue was with libiconv, fortunately this is easily installed with brew install libiconv. Rerunning php install php71 solved the problem
I specifically had to uninstall the offending version. You can grab this broken version from the line that looked like this:
Referenced from: /usr/local/Cellar/php#7.1/7.1.23/bin/php
In OP's case, it was php#7.1. In my case it was php#7.3. After I ran the following based on my situation, everything worked
brew uninstall php#7.3
For those who can not resolve by brew install openldap libiconv,
try below command:
brew reinstall openldap
brew reinstall php#7.4
brew services restart php#7.4
This issue is discussed and tracked at https://github.com/Homebrew/homebrew-core/issues/32916
if you have two PHP running via brew as well a XAMPP, there could be issue in environment path in .bash_profile.
which php
Try above command to see current php path. If it not accurate, set appropriate path and comment other.
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
#export PATH=”/usr/local/opt/php#5.6/bin:/usr/local/opt/php#5.6/sbin:$PATH
After trying all above solutions. Finally uninstalling and reinstalling worked for me.
brew uninstall php
brew install php
For me, after running the following commands:
brew reinstall openldap
brew reinstall php#7.4
brew services restart php#7.4
I had to restart my computer for the error to stop and everything worked fine.
The code is working fine on Ubuntu vagrant box, but on local MacOs it does not load sertificates saying
cURL error 58: SSL: Can't load the certificate "..." and its private key: OSStatus -25299
I researched that Mac has a point of supporting the OS X native API instead of OpenSSL.
And I need to convert a pem + cert to pkcs12 like that.
openssl pkcs12 -export -in ./client.crt -inkey ./client.pem -out client.p12
But this is not working for me because my PHP server is on Ubuntu and I don't want to break what is working. My task is to make it work on Mac.
I would rather install curl with openssl support. I tried this:
$ brew uninstall curl
$ brew install curl --with-openssl
$ brew link curl --force
$ curl --version
But it did not solve the problem.
Please tell me what am I did wrong.
Thank you.
installing curl via brew and with openssl support as outlined in the question is the correct approach. however you need to explicitly call it from its install dir /usr/local/opt/curl/bin/curl -v -k --key.. as brew wont link it to /usr/local as stated on install
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig
PHP was not working for me as I was encountering this libpng issue, so I reinstalled a new version with Homebrew.
However, I'm getting a similar error with libjpeg this time:
$ php -v
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Trace/BPT trap: 5
Any suggestions?
As proposed by #jirson-tavera in the homebrew-php repo issue, this can be fixed without overriding your brew installation:
wget -c http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar xzf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure
make
cp ./.libs/libjpeg.8.dylib /usr/local/opt/jpeg/lib
Even though the solution in the accepted answer works, it's not the right way to fix the problem. It violates brew's metadata integrity.
Problem
The issue is that Homebrew's jpeg formula has been upgraded to v9 but the existing "bottled" PHP formula is still built and linked against the previous version, v8, which is no longer exists on your system.
You have a few options to fix the issue.
1. Recompile phpxx formula from source (highly recommended)
Uninstall your php formula, and rebuild it from the source instead of using the bottled version. This way, php will use and link against the currently installed version of jpeg. Assuming that you're dealing with php71:
brew reinstall php71 --build-from-source
2. Downgrade jpeg formula the right way (preferred over recompiling it manually)
If you haven't run brew cleanup, you already got the previous jpeg version in your brew's cellar, switch to it:
brew switch jpeg 8d
If you get a jpeg does not have a version "8d" in the Cellar. error, you need to first restore it by reverting the history:
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout b231469
HOMEBREW_NO_AUTO_UPDATE=1 brew install jpeg
git checkout master
brew switch jpeg 8d
You can find out the commit hash by using brew log jpeg and going through the commit messages.
The downside is that there might be other formulas that require the newer version to work properly, e.g. imagemagick. If you face such incompatibility issues, check the first solution above.
3. Downgrade jpeg by manually recompiling (not recommended)
Fetch the source, compile and overwrite brew's version. Refer to Denis' answer for details.
This is not recommended because it violates the integrity of your brew metadata. Brew thinks that it has the 8b version, however, you manually compiled 9b and overwrote the files.
4. Manually symlink the old version (seriously?)
Do not manually symlink the leftover libjpeg.8.dylib. If the file is there, you can just brew switch to it as mentioned in the second solution above.
It's just the worst hack you can do here.
Such issues will be eventually fixed.
I encountered the similar problem today. The cause of the problem was a newer version of libjpeg. And the solution that worked was building php bottle from source.
Check available version of libjpeg:
$brew info libjpeg
jpeg: stable 9b (bottled)
Image manipulation library
http://www.ijg.org
/usr/local/Cellar/jpeg/9b (20 files, 724KB) *
Poured from bottle on 2017-08-07 at 12:06:42
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/jpeg.rb
Install php from source:
brew install --build-from-source php56
Update:
If you have already installed php you have to uninstall it prior to building from source. It also applies to extensions.
I had the same problem and I solved it by downloading the libjpeg tarball manuallu from here and running:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a #Optionally
I was getting a similar problem trying to upgrade composer:
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
composer: PHP Phar support is required for this formula
Error: An unsatisfied requirement failed this build.
Problem was php couldn't find libjpeg library anymore. One way to fix this is to reinstall php and libjpeg. Here's how I reinstalled them:
# find out which version of php is installed
brew list | grep php
# uninstall php
brew uninstall php70 --ignore-dependencies
# uninstall libjpeg
brew uninstall libjpeg --ignore-dependencies
# install libjpeg again
brew install libjpeg
# install php again
brew install php70
I was then able to upgrade everything again :)
brew update && brew upgrade
🍻
Following command worked for me.
brew switch libjpeg 8d
A dirty solution, that work fine for me.
ln -s /usr/local/lib/libjpeg.9.dylib /usr/local/lib/libjpeg.8.dylib
I didn't try Jirson's answer, but what worked for me was:
brew uninstall libjpeg
brew install libjpeg
I was having the same problem and the only thing that helped was to use the --build-from-source parameter:
brew install php70 --build-from-source
I had also this problem. I solved it in this way:
Uninstall jpeg/8b:
brew uninstall --ignore-dependencies libjpeg
Uninstall jpeg/9b:
brew uninstall --ignore-dependencies jpeg
Re install jpeg/9b
brew install jpeg
I am sharing this as I had the same issue when using PHP5.4. Originally, I had PHP5.6 and it was working fine. Then I downgraded to php5.4 as my app only supports PHP5.4.
Then this error came up. I noticed that I have libjpeg.9.dylib and PHP5.4 is looking for libjpeg.8.dylib.
Doing the following sorted the issue:
brew uninstall php54
brew install --build-from-source php54
As #lifecom notes, this is fixed with homebrew's php70 update, but you might still run into the problem if brew upgrade is trying to update other packages before upgrading php70.
Fix this by manually updating php70 first with brew upgrade php70 and you then should be able to run brew upgrade no problem (or, well, at least without this problem).
In some cases, especially in Catalina, the Homebrew cask for the package may exist but not be properly linked. In that case try:
brew link libjpeg
brew reinstall php --build-from-source
Homebrew php has been updated and no longer an issue with libjpeg
I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report.
I've gone into my php.ini file and added
extension=pgsql.so
But, I'm met with the following error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pg_connect() in... (blah file here)
When running phpinfo(), I see nothing about PostgreSQL, so what is my issue here?
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
Find your version of PHP: php -v.
Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
Type phpize.
Type ./configure.
Type make.
Type sudo make install.
Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
Type sudo chown -R $USER /usr/local/Cellar.
Type brew update.
Type brew install autoconf.
That should install autoconf and allow you to install the module using the instructions above.
If you use home brew, you can solve this with a command as simple as:
brew install php55-pdo-pgsql
for other php version, search with:
brew search pgsql
This worked for me with OSX 10.9.4 «Mavericks»
Install sources
Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:
tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP
cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module
I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:
cd ext/pdo_pgsql
In my case I had the following error:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. ERROR:
`phpize' failed
So I had to use this command:
brew install autoconf
Then:
phpize
After that I tried to do:
./configure
but I had the next problem:
checking for pg_config... not found configure: error: Cannot find
libpq-fe.h. Please specify correct PostgreSQL installation path
So the solution was to specify correct PostgreSQL installation path:
./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.
Then simply add
extension=pdo_pgsql.so to /etc/php.ini
Run php -m to confirm everything went to plan.
For those who installed php7/ngix/postgres with homebrew
You can install the PostgreSQL module with:
brew install php70-pdo-pgsql
After that, you have to restart the php service:
brew services restart php70
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
For php56 via brew:
brew install php56-pdo-pgsql
PostgreSQL by default is installed in a unusual place on MAC OS X:
/Library/PostgreSQL/9.3
Given the location above you can type this:
./configure --with-pgsql=/Library/PostgreSQL/9.3
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so.
Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.
For those of you having openssl error while make here is the solution
OSX uses openssl 0.98 while installer is searching for 1.0.0
refer this link for instructions
psycopg2 installation error - Library not loaded: libssl.dylib
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.
To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.