简体   繁体   中英

PHP Startup : Unable to load dynamic library 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() 结果

Can anyone help me on this one ?

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

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

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!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM