17

I have a ubuntu 14.4 server with apache2 and php 7.1.6.

I also have PostgreSQL 9.3 installed on it. I now need to connect to this data from php code, using PDO.

I have tried the following:

  1. Install Pgsql driver with: sudo apt install php7.0-pgsql
  2. Now when I try to enable postgres PDO drivers using sudo phpenmod pdo_pgsql, I get the following error messages:

WARNING: Module pdo_pgsql ini file doesn't exist under /etc/php/7.1/mods-available

How do you correctly install & enable the PDO drivers for PostGres for php 7?

21

You've been running php7.1 while you installed php7.0 pgsql module.

Try php -v to check your version and install php7.1-pgsql.

3

Also you need to uncomment these lines:

extension=php_pdo_pgsql.dll
extension=php_pgsql.dll

in /etc/php/7.1/cli/php.ini .

1
  • 1
    Also, sudo phpenmod pdo_pgsql – Glorious Kale Apr 28 '20 at 10:03
1

In addition to what others said, try:

sudo phpenmod pdo_pgsql
1
  • Please be specific. Which other commands should one use before the one you wrote? Otherwise the answer is not complete. – user68186 May 1 '20 at 15:38
0

I have tried the following:

  1. Try php -v to check your version
  2. Install php7.1-pgsql
  3. Enable postgres PDO drivers using sudo phpenmod pdo_pgsql
  4. Restart postgres service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.