15

I'am trying to run Symfony 3.x with :

  • Ubuntu 16.04
  • PHP 7.0
  • NGinx

I would like to interact with my PGSQL database that I created but I get this error :

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_pdo_pgsql.dll' - /usr/lib/php/20151012/php_pdo_pgsql.dll: cannot open shared object file: No such file or directory in Unknown on line 0

[Doctrine\DBAL\Exception\DriverException] An exception occured in driver: could not find driver
[Doctrine\DBAL\Driver\PDOException] could not find driver

[PDOException] could not find driver

So I looked at my phpinfo() and it seems that pgsql driver is enabled

phpinfo() result

Can anyone help me on this one ?

Neodan
  • 5,154
  • 2
  • 27
  • 38
Hurobaki
  • 3,728
  • 6
  • 24
  • 41

6 Answers6

7

You must properly install the PostgreSQL module and enable it. http://php.net/manual/en/pgsql.installation.php

P.S. do not use '.dll' files on the servers with UNIX based OS, because these extensions are compiled for the Windows operating system (for UNIX based OS you must use '.so' files).

Neodan
  • 5,154
  • 2
  • 27
  • 38
  • I already tried it and it says that php7.0-pgsql is already the newest version :/ Do I have to remove it and re-install ? – Hurobaki Jul 13 '17 at 08:57
  • 1
    php_pdo_pgsql.dll is an extension compiled for Windows operating system. (-; – Neodan Jul 13 '17 at 09:02
  • I get it but I don't know how I did to get .dll instead of .so ... ^^ – Hurobaki Jul 13 '17 at 09:04
  • did you try to remove 'extension=php_pdo_pgsql.dll' from your php.ini file? – Neodan Jul 13 '17 at 09:10
  • I tried to comment it in /etc/php/7.0/fpm/php.ini then I restarted php and nginx but I still get this error :/ Is there somewhere else I should comment it ? – Hurobaki Jul 13 '17 at 09:17
  • @Hurobaki Take a look into your phpinfo() to be sure that you are using exactly this php.ini file – Neodan Jul 13 '17 at 09:28
  • I wanted to let you know that properly re-install PostgreSQL module with correct PHP version and comment .dll in my php.ini worked ! Thank you for your help :) – Hurobaki Jul 18 '17 at 12:58
4

I had a very similar issue:

I fixed it by applying the same patch as for this subject: pdo_parse_params error in pdo_odbc.so whenever PHP starts in Fedora 20

In a nutshell: if a module has already been loaded by the /etc/php/7.2/mods-available/<module>.ini (or equivalent path for your OS), then the module should not be uncommented (= made active) in the php.ini files. (two of them, cli and server).

You may ensure this, by checking phpinfo(), and observe how pdo_pgsql is still active in there, despite the line being commented in php.ini!

Fabien Haddadi
  • 1,814
  • 17
  • 22
  • Yes, solution can be to go back to the used `php.ini` (CLI) and just comment it out back with `;` :D – jave.web Aug 30 '19 at 20:43
4

For me, none of the above solutions worked. Uncommenting extension=pgsql in php.ini also didn't work in and of itself.

It seemed as if postgresql wasn't installed even though I had installed it on my Ubuntu using

sudo apt-get install postgresql-12 

Finally, I realized I had to install:

sudo apt-get install php-pgsql
1

I had a similar problem and (after installing the PHP pg driver) I had to add two files to /etc/php.d

20-pgsql.ini

extension=pgsql.so

30-pdo-pgsql.ini

extension=pdo_pgsql.so

Putting these extension config lines in the php.ini kept giving me the pdo_parse_params error

Nick
  • 138,499
  • 22
  • 57
  • 95
Arquin
  • 11
  • 2
0

The only solution that seemed to work for me was to comment out extension=pdo_pgsql and extension=pgsql inside /etc/php8.1/cli/php.ini by adding ; in front of the them:

;extension=pdo_pgsql
;extension=pgsql

This is for PHP version 8.1

-1

comment out extension=pdo_pgsql and extension=pgsql inside /etc/php8.1/cli/php.ini by adding ; in front of the them:

  • ;extension=pdo_pgsql
  • ;extension=pgsql
  • Have to downvote this answer because this answer doesn't seem to be appropriate to the asked question. The question clearly states that the PHP version used in the environment is v7 and this answer doesn't suits it. And the questioner clearly explains that there is a misconfiguration in php.ini that is trying to load a nonexistent pdo_pgsql.dll extension that's not exist in Linux (Ubuntu) environment. – Saravanakumar Arumugam May 25 '23 at 13:51