postgresql 为 postgres Ubuntu 安装 pdo
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7180869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install pdo for postgres Ubuntu
提问by Richard Pérez
I am trying to enable the pdo driver for my php installation, but when I runn the command
我正在尝试为我的 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
I get
我得到
"Unable to build the PDO PostgreSQL driver: libpq 7.4+ is required"
I install postgresql in that directory
我在该目录中安装了 postgresql
/usr/local/webserver/postgres
I installed postgresql 9.0.4.1 using the bin package and using php 5.3
我使用 bin 包和使用 php 5.3 安装了 postgresql 9.0.4.1
回答by Alex
Pecl PDO package is now deprecated. By the way the debian package php5-pgsql now includes both the regular and the PDO driver, so just:
Pecl PDO 包现已弃用。顺便说一下,debian 包 php5-pgsql 现在包含常规和 PDO 驱动程序,所以只需:
apt-get install php-pgsql
Apache also needs to be restarted before sites can use it:
Apache 还需要重新启动,站点才能使用它:
sudo systemctl restart apache2
回答by wildpeaks
Try the packaged pecl version instead (the advantage of the packaged installs is that they're easier to upgrade):
试试打包的 pecl 版本(打包安装的优点是它们更容易升级):
apt-get install php5-dev
pecl install pdo
pecl install pdo_pgsql
or, if you just need adriver for PHP, but that it doesn't have to be the PDO one:
或者,如果您只需要一个PHP 驱动程序,但它不一定是 PDO 驱动程序:
apt-get install php5-pgsql
Otherwise, that message most likely means you need to install a more recent libpq package. You can check which version you have by running:
否则,该消息很可能意味着您需要安装更新的 libpq 包。您可以通过运行来检查您的版本:
dpkg -s libpq-dev
回答by Dylan Pierce
If you're using the wonderful ondrej/php
ubuntu repository with php7.0:
如果您在ondrej/php
php7.0 中使用出色的ubuntu 存储库:
sudo apt-get install php7.0-pgsql
For ondrej/php
Ubuntu repository with php7.1:
对于ondrej/php
带有 php7.1 的 Ubuntu 存储库:
sudo apt-get install php7.1-pgsql
Same repository, but for php5.6:
相同的存储库,但对于 php5.6:
sudo apt-get install php5.6-pgsql
Concise and easy to remember. I love this repository.
简洁易记。我喜欢这个存储库。
回答by Will
PDO driver for PostgreSQL is now included in the debian package php5-dev. The above steps using Pecl no longer works.
PostgreSQL 的 PDO 驱动程序现在包含在 debian 软件包 php5-dev 中。上述使用 Pecl 的步骤不再有效。
回答by joan16v
If you are using PHP 5.6, the command is:
如果您使用的是 PHP 5.6,则命令为:
sudo apt-get install php5.6-pgsql