我查看了多个 SO 线程,但似乎都没有我的问题。我已经编译并安装了 pro_pgsql 扩展,如下所示:http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks并通过运行 php -m
验证它已加载,apache 已重新启动,php_info 显示以下内容:
但是当我运行这个脚本时:
echo "hi!";
$ebdb_conn = pg_connect('dbname=mydb user=frank password=frank123') or die(pg_last_error());
我在日志中收到以下错误:
[Mon Jun 09 12:39:05 2014] [error] [client ::1] PHP Fatal error: Call to undefined function pg_connect() in /Users/frank/Code/ebus/test.php on line 4
这是在 OSX Mavericks 上,使用 Apache 和 PHP 5.2.24。有什么想法吗?
最佳答案
这个问题最终通过卸载与 Enterprise DB postgres 包有关的所有内容并使用一组一致的包重新安装来解决。不幸的是,我的机器上仍然有一个不匹配的 psql 客户端,但除此之外它工作正常。对于其他人看到这一点,我建议:
不要使用在 OSX Mavericks 上的 postgres 网站上找到的企业数据库安装程序使用以下之一
1) postgres 应用程序 ( http://postgresapp.com ) 很好,因为它内置了 postGIS 和其他扩展
2) 映射端口包 ( https://trac.macports.org/browser/trunk/dports/databases/postgresql82/Portfile )
3) brew 安装程序 ( http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/ )
关于php - osx mavericks 上的 pg_connect 未定义函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24126950/