Question

PHP Startup: Unable to load dynamic library 'pdo_pgsql' on Ubuntu 18.04

Posted May 31, 2021 133 views
UbuntuApacheServer OptimizationUbuntu 18.04

I have been having an issue in my server for a while now. My php keeps returning a warning
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20170718/pdo_pgsql (/usr/lib/php/20170718/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_pgsql.so (/usr/lib/php/20170718/pdo_pgsql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Anytime this error is returned, my server request fails and hence my system fail.

I cannot install anything using apt or dpkg because all packages are broken. I don’t know how to fix this issue and any ideas or guide will be appreciated.

I currently run php 7.2 and I believe this issue started when I wanted to install php 7.3 and it failed. Apache server, Yii2 framework

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @abebohmuzikol,

Can you try removing your pdo_pgsql PHP driver with apt to see if that would work first:

apt remove pdo_pgsql

or

apt remove php-pgsql

You might need to add the version are using 7.3

apt remove php73-pgsql

You must properly install the PostgreSQL module and enable it. (http://php.net/manual/en/pgsql.installation.php)[PHP PHSQL installation]

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

  • Thanks for the response. apt, apt-get or dpkg commands doesn’t work.
    When I run php -v, I get the result

    PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20170718/pdo_pgsql (/usr/lib/php/20170718/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_pgsql.so (/usr/lib/php/20170718/pdo_pgsql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    
    

    So I don’t know what next to do.

    • Hi @abebohmuzikol,

      Can you please try to remove your php-8 packages like so:

      apt remove php8.0-soap php8.0-pgsql
      

      I saw in the error messages you provided that those are saying they have an issue. Try removing them. Does apt remove work as opposed to apt-get?