Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pdo for postgres Ubuntu

Tags:

postgresql

pdo

I am trying to enable the pdo driver for my php installation, but when I runn the command

./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

/usr/local/webserver/postgres 

I installed postgresql 9.0.4.1 using the bin package and using php 5.3

like image 448
Richard Pérez Avatar asked Aug 24 '11 19:08

Richard Pérez


2 Answers

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:

apt-get install php-pgsql 

Apache also needs to be restarted before sites can use it:

sudo systemctl restart apache2 
like image 67
Alex Avatar answered Sep 20 '22 11:09

Alex


Try the packaged pecl version instead (the advantage of the packaged installs is that they're easier to upgrade):

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

or, if you just need a driver for PHP, but that it doesn't have to be the PDO one:

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:

dpkg -s libpq-dev 
like image 38
wildpeaks Avatar answered Sep 22 '22 11:09

wildpeaks