【问题标题】:pg_connect undefined function on osx mavericksosx mavericks 上的 pg_connect 未定义函数
【发布时间】:2014-06-09 18:53:52
【问题描述】:

我查看了多个 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。有什么想法吗?

【问题讨论】:

    标签: php macos postgresql


    【解决方案1】:

    这个问题最终通过卸载与 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/)

    【讨论】:

      【解决方案2】:

      pg_connect 不是 PDO 库的一部分。它包含在 PHP 的直接 postgresql 库中。在 MacPorts 中,就是 php5-postgresql,macports 从 http://lil.fr.packages.macports.org/php5-postgresql 获取。

      【讨论】:

      • 我安装了 macports 和 sudo port install php5-postgresql,然后是 sudo apachectl restart 同样的错误。我错过了什么吗?
      • 听起来您正在使用两组不同的安装说明来达到相同的目标。在 OP 中,我假设您正在从源代码安装所有内容,并且需要 pg_connect 的代码库。如果您只是想知道在 Mavericks 上安装 PHP 和 PostgreSQL 的最简单方法,那就是另一个问题了。
      • MacPorts 的安装说明:macports.org/install.php 然后安装 php 和 postgresql:sudo port install php5-postgresql。
      • 我最初从 EnterpriseDB 安装了 postgres(即 postgres 站点上的链接),但已经卸载并重新安装了 mac 端口包 postgresql93-serverphp54-postgresql 并且仍然有相同的错误。我缺少的任何东西?
      猜你喜欢
      • 2016-10-02
      • 2013-09-25
      • 2017-02-21
      • 1970-01-01
      • 2013-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多