Skip to content
Advertisement

how to enable php pdo driver for Postgres on Ubuntu 18.04

I installed php 7.2 and php 7.3 on Ubuntu 18.04, and created a php file to log on to and insert data into the Postgres database. My script responded “could not find driver.”

Research turned up that I have to edit the php.ini files and enable the extensions for Postgres and PDO. Below are all the extension= lines in the php.ini files. The closest I could find are the pdo lines shown below.

JavaScript

So I edited the php.ini files and removed the semi-colons from each of those lines to enable them. Then I restarted Apache2:

JavaScript

But I still get “could not find driver.”

This is the entire listing of extensions from the php.ini files. Which other extensions do I need to enable to allow PDO access to Postgres?

php.ini 7.3

JavaScript

php.ini 7.2

JavaScript

This is the php logon script (the logon credentials are replaced with dummy values here because I can’t reveal them):

JavaScript

Then I edited the two .ini files and added “.so” at the end of each of the two lines and restarted Apache2, but I still get the same error message.

Thanks for any ideas.

Advertisement

Answer

I think you’re missing the php-pgsql library, run the following commands and it should start working (keep the changes for the php.ini files):

JavaScript

I do not have Ubuntu which means the library names could be different.

Hope it helps

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement