alistairphillips.com

I’m : a web and mobile developer based in the Australia.


Enable PostgreSQL PDO support on OS X

Almost entirely sourced from http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x but I'm keeping a copy for myself along with my tweaks.

OS X 10.10 comes with PHP 5.5.20 which you'll need to grab from http://php.net/get/php-5.5.20.tar.bz2/from/a/mirror

I'm running my copy of PostreSQL from Postgres.app so get a copy and install to your Applications folder.

cd ~/Downloads
tar -jxvf php-5.5.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.5.20 /usr/include/php
cd /usr/include/php
./configure --without-iconv
cd ext/pdo_pgsql
brew install autoconf
phpize
./configure --with-pdo-pgsql=/Applications/Postgres.app/Contents/Versions/9.4/
make
sudo cp pdo_pgsql.so /usr/lib/php/extensions/no-debug-non-zts-20121212

In checking php | grep ini I spotted that the base install was expecting additional configuration files within /Library/Server/Web/Config/php. That didn't exist so I created it along with in ini file containing extension=pdo_pgsql.so

sudo mkdir /Library/Server/Web/Config/php

With that done php -m should now list pdo_pgsql as an included module