views:

136

answers:

1

I have Snow Leopard and am using the default apache. I installed postgresql via macports. So now I can do a psql from a terminal (I tried but failed to do a install of php5 through macports but there was an error)

I have enabled php5 and restarted the apache so now I have php. But for the life of me I cannot figure out to hook up postgresql to work with php. I'm trying to do a pg_connect() and I get

"Fatal error: Call to undefined function pg_connect() in /private/var/www/html/sheep/connect.php on line 4"

I have put

extension=pgsql.so
extension=pdo_pgsql.so

In the php.ini file. My phpinfo says my extension_dir=/usr/lib/php/extensions/no-debug-non-zts-20090626

I went to /usr/lib/php/extensions/no-debug-non-zts-20090626 directory on my mac and actually put pgsql.so and pdo_pgsql.so in that directory from MAMP. I did a locate in the terminal for pgsql.so and it existed in my MAMP directory. I don't want to use MAMP anymore but thought maybe I could move the .so file and use it.

Do I have to recompile php with postgresql? Do I have to do something special to get a non MAMP pgsql.so file? I didn't know what pdo_pgsql.so but I thought I would try it so that is why it is in there.

A: 

The easiest way is jsut to use all the packages from Macports:

sudo port install apache2 postgresql83 php+postgresql83+mysql5+pear+apache2

Otherwise you are going to have to download source and compile manually... you cant use the binaries provided by mamp unless you use mamp.

prodigitalson
Thanks prodigitalson. I got hung up from macports. It was trying to install db64 and there were checksum errors so nothing was compiled. I finally found how to fix the problem here...http://laurii.info/articles/2010/08/15/macports-berkley-db-4-problem-and-work-around
Keith
Ooooh.. thanks for that. I may be gettign a new machine shortly and im sure i would run into this as well. You probably jsut saved me a couple hours of workstation build time :-)
prodigitalson