为postgres Ubuntu安装pdo

问题描述 投票:38回答:5

我正在尝试为我的php安装启用pdo驱动程序,但是当我运行该命令时

./configure --prefix=/usr/local/webserver/php --with-apxs2=/usr/local/webserver/apache2/bin/apxs --enable-mbstring --enable-intl --with-icu-dir=/usr --with-pgsql=/usr/local/webserver/postgres --with-pdo-pgsql=/usr/local/webserver/postgres

我明白了

"Unable to build the PDO PostgreSQL driver: libpq 7.4+ is required"

我在该目录中安装postgresql

/usr/local/webserver/postgres

我使用bin包并使用php 5.3安装了postgresql 9.0.4.1

postgresql pdo
5个回答
82
投票

Pecl PDO包现已弃用。顺便说一下,debian包php5-pgsql现在既包括常规驱动程序也包含PDO驱动程序,所以只需:

apt-get install php-pgsql

在站点可以使用Apache之前,还需要重新启动Apache:

sudo systemctl restart apache2

24
投票

请尝试使用打包的pecl版本(打包安装的优点是它们更容易升级):

apt-get install php5-dev
pecl install pdo
pecl install pdo_pgsql

或者,如果您只需要PHP的驱动程序,但它不必是PDO:

apt-get install php5-pgsql

否则,该消息很可能意味着您需要安装更新的libpq软件包。您可以通过运行来检查您拥有的版本:

dpkg -s libpq-dev

18
投票

如果您使用php7.0的精彩ondrej/php ubuntu存储库:

sudo apt-get install php7.0-pgsql

对于带有php7.1的ondrej/php Ubuntu存储库:

sudo apt-get install php7.1-pgsql

相同的存储库,但对于php5.6:

sudo apt-get install php5.6-pgsql

简洁易记。我喜欢这个存储库。


8
投票

PostgreSQL的PDO驱动程序现在包含在debian软件包php5-dev中。使用Pecl的上述步骤不再有效。


1
投票

如果您使用的是PHP 5.6,则命令为:

sudo apt-get install php5.6-pgsql
© www.soinside.com 2019 - 2024. All rights reserved.