Mac系統自帶了php,不過沒有攜帶pgsql擴展庫。網上找了好久都是說要使用源代碼自行編譯。
php擴展庫編譯方法如下:
1、使用 php -v 查看當前php版本
2、下載對應的原文件,比如 php-5.5.7.tar.gz
3、執行 tar -zxvf php-5.5.7.tar.gz
4、執行 cd php-5.5.7
/ext/pgsql/
5、執行 phpize
6、執行 ./configure //這裏可能需要你使用 --with-pgsql指定postgresql安裝路徑,
// 如果你是使用的postgresql.app,可以寫./configure --with-pgsql=/Applications/Postgres93.app/Contents/MacOS
7、執行 make
8、執行make install
9、修改php.ini文件,添加 extension=pgsql.so
10、重啓apache
原文鏈接:http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x
後來還是重新編譯了5.5.7
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/opt/libxml2/ --with-png-dir=/usr/local/opt/libpng/ --with-jpeg-dir=/usr/local/opt/jpeg --with-gd=/usr/local/ --with-zlib-dir=/usr/local/zlib/ --with-mcrypt=/usr/local/Cellar/mcrypt/2.5.8
--with-mysql=/usr/local/mysql --enable-soap --enable-mbstring=all --enable-sockets --enable-pdo --with-pdo-mysql=/usr/local/mysql --with-pgsql=/Applications/Postgres93.app/Contents/MacOS --with-freetype-dir=/usr/local/opt/freetype