Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Startup : Unable to load dynamic library PGSQL

Tags:

php

pdo

php-pgsql

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 ?

like image 232
Hurobaki Avatar asked Jul 13 '17 08:07

Hurobaki


4 Answers

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
like image 151
Rohan Hussain Avatar answered Oct 30 '22 18:10

Rohan Hussain


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

like image 25
Neodan Avatar answered Oct 30 '22 18:10

Neodan


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!

like image 3
Fabien Haddadi Avatar answered Oct 30 '22 16:10

Fabien Haddadi


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

like image 1
Arquin Avatar answered Oct 30 '22 18:10

Arquin