Kim's Adventures into Geekspace

To content | To menu | To search

Postgres.app, PHP and Mavericks

Update 10 November 2013: after updating Mavericks from GM to build 13A603, everything broke again. After recompiling like specified below nothing was working and there may have been a missing path somewhere in the php.ini-file. While tracking the error down, I stumbled over a new version of PHP with a one-line install on http://www.coolestguidesontheplanet.com. I decided on 5.5 while I was at it.:

easy PHP 5.5-installation

Just running the installation command, a curl, the postgres-connection was working again, even from a non-standard postgres-installation. Thumbs up.

--

I updated a few of my computers to Mac OS X 10.9 Mavericks. Everything went fine, or so I thought until my wife complained about a missing blog. I happen to run this blog on Dotclear using a Postgres.app-database. Dotclear is of course using php and Apache.

Soon it was clear that the good folks at Apple have dropped support for Postgres in their php-configuration, so what to do. But I found this rather helpful page:

http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks

It was not perfect though, as a few steps were a bit shorthanded: installing autoconf from brew for instance, but that was fairly easy after a bit of googling, so I won’t repeat those steps here. See here, if you like.

I think that Rupey gets it very right for the rest, that is if you have Postgres installed by hand, i.e. that it is comfortably sitting in /usr/local/pgsql/ or similar. Given that I had used the app-version - much simpler to install and run - I had to point the configuration to the right directory. So when doing this

cd ext/pdo_pgsql

phpize

./configure

I ended up with this error:

checking for pg_config... not found

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

To point out the right installation path I just had to do this:

./configure --with-pdo-pgsql=/Applications/Postgres.app/Contents/MacOS/bin

before doing the rest:

make

sudo make install

and finally adding extension=pdo_pgsql.so to /etc/php.ini (and changing the time zone) and doing a sudo httpd -k graceful to make php work with Postgres again. Sorry for the downtime, btw.

Comments

1. On Thursday, November 7 2013, 20:41 by Rui

Thanks! Saved my life that ./configure command... tried lots of options before and nothing!
Really appreciated :)

2. On Thursday, January 16 2014, 16:55 by mybofy

I don't have Postgres.app !
But PG works fine...

I use :
>> ./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3
It works.

3. On Saturday, March 15 2014, 17:34 by Graymalkin

If your are using the Postgres from here: http://postgresapp.com, this command will work: ./configure --with-pdo-pgsql=/Applications/Postgres.app/Contents/Versions/9.3/bin/

4. On Wednesday, May 14 2014, 23:24 by Gino Barahona

Finally!! Thanks, only two things i had to change:
--with-pdo-pgsql by --with-pgsql and extension=pdo_pgsql.so by extension=pgsql.so