简体   繁体   English

PHP 启动:无法加载动态库 PGSQL

[英]PHP Startup : Unable to load dynamic library PGSQL

I'am trying to run Symfony 3.x with :我正在尝试使用以下命令运行 Symfony 3.x:

  • Ubuntu 16.04 Ubuntu 16.04
  • PHP 7.0 PHP 7.0
  • NGinx金克斯

I would like to interact with my PGSQL database that I created but I get this error :我想与我创建的 PGSQL 数据库进行交互,但出现此错误:

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 PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php/20151012/php_pdo_pgsql.dll' - /usr/lib/php/20151012/php_pdo_pgsql.dll:无法打开共享对象文件:没有这样的文件或目录在未知的第 0 行

[Doctrine\\DBAL\\Exception\\DriverException] An exception occured in driver: could not find driver [Doctrine\\DBAL\\Exception\\DriverException] 驱动程序发生异常:找不到驱动程序
[Doctrine\\DBAL\\Driver\\PDOException] could not find driver [Doctrine\\DBAL\\Driver\\PDOException] 找不到驱动

[PDOException] could not find driver [PDOException] 找不到驱动程序

So I looked at my phpinfo() and it seems that pgsql driver is enabled所以我查看了我的phpinfo()似乎启用了 pgsql 驱动程序

phpinfo() 结果

Can anyone help me on this one ?谁能帮我解决这个问题?

You must properly install the PostgreSQL module and enable it.您必须正确安装 PostgreSQL 模块并启用它。 http://php.net/manual/en/pgsql.installation.php 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). PS 不要在基于 UNIX 的操作系统的服务器上使用“.dll”文件,因为这些扩展是为 Windows 操作系统编译的(对于基于 UNIX 的操作系统,您必须使用“.so”文件)。

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我通过应用与此主题相同的补丁来修复它: pdo_odbc.so 中的 pdo_parse_params 错误,每当 PHP 在 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.简而言之:如果一个模块已经被/etc/php/7.2/mods-available/<module>.ini (或你的操作系统的等效路径)加载,那么模块不应该被取消注释(= 激活)在 php.ini 文件中。 (two of them, cli and server). (其中两个,cli 和服务器)。

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!您可以通过检查 phpinfo() 来确保这一点,并观察 pdo_pgsql 在那里仍然处于活动状态,尽管在 php.ini 中注释了该行!

I had a similar problem and (after installing the PHP pg driver) I had to add two files to /etc/php.d我遇到了类似的问题,并且(安装 PHP pg 驱动程序后)我不得不将两个文件添加到 /etc/php.d

20-pgsql.ini 20-pgsql.ini

extension=pgsql.so

30-pdo-pgsql.ini 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将这些扩展配置行放在 php.ini 中不断给我 pdo_parse_params 错误

For me, none of the above solutions worked.对我来说,上述解决方案都没有奏效。 Uncommenting extension=pgsql in php.ini also didn't work in and of itself.在 php.ini 中取消注释 extension=pgsql 本身也不起作用。

It seemed as if postgresql wasn't installed even though I had installed it on my Ubuntu using即使我使用 Ubuntu 在我的 Ubuntu 上安装了 postgresql,它似乎也没有安装

sudo apt-get install postgresql-12 

Finally, I realized I had to install:最后,我意识到我必须安装:

sudo apt-get install php-pgsql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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