Setting up Postgresql to work with my local dev
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 开发者_Python百科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.
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.
精彩评论