【发布时间】:2023-03-22 18:17:01
【问题描述】:
我在我的大学计算机上运行了一个带有 postgresql 的 PHP 服务器,它运行良好,但是在我的本地计算机(运行 MacOS)上,我收到以下错误消息:
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
现在,我认为这是缺少 php 的 postgresql 包的问题,所以我使用 brew 安装了 php postgresql 包。我运行了以下命令:
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
但是,即使在运行这些命令后,我在运行 php 服务器时也会遇到同样的错误,即
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
我的php版本是5.5.30:
mac$ php -v
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
请您建议我在安装软件包时做错了什么。我在堆栈溢出中读到,可以在 linux 上使用 apt-get 命令安装这些软件包,但是我不确定 Mac 操作系统的解决方案是什么。
提前致谢。
【问题讨论】:
-
请运行
postgres -V命令并检查您的 posgress 版本。如果 postgress 安装正确,它会显示版本号和详细信息。 -
您好,感谢您的回复。我认为 postgres 安装正确,但我无法通过 php 访问它,例如我无法使用 php 中的 pg_connect() 等函数。
-
我从 postgres -V 得到以下输出:postgres (PostgreSQL) 10.3
标签: php bash macos postgresql homebrew