1 Reply Latest reply: Aug 23, 2011 6:12 PM by etresoft
Transini Level 1 (135 points)

On a 10.6.8 OSX Server system I'm trying to install PostgreSQL to test things out before we upgrade to Lion, but I can't get PHP5 to include PostgreSQL support. Here's what I've tried:

 

- sudo port postgresql90

- sudo port postgresql90-server

- sudo port php5 +postgresql

- inserting the line "extension=pgsql.so" into /etc/php.ini

- rebooting

 

Interactively, a new PHP is there and psql is there, but when I attempt to connect to a PostgreSQL database from a PHP script in a web browser I get:

 

PHP Fatal error:  Call to undefined function pg_connect()

 

Doing a phpinfo() interactively in the Terminal shows the new version of PHP is there and has psql support built in. But doing this in the browser shows PHP is still at 5.3.4 and there's no reference to PostgreSQL. Doing a extension_loaded('pgsql') returns a null. Is Apache somehow built against a version of PHP without PostgreSQL?

 

How can I get this going?

  • etresoft Level 7 (27,848 points)

    Those port packages are 3rd party tools. They do not affect the system-installed versions of PHP. You would have to either replace Apache's PHP module or replace the system Apache with a "port" version.

     

    Instead of replacing PHP, I suggest following this tutorial to add the PostgreSQL extension to the system PHP.