Score:0

Uncaught Error: Call to undefined function pg_connect()

us flag

I have following server cofiguration:

  • Ubuntu 20.04.3 LTS
  • PHP 7.4.13 (cli)
  • psql (PostgreSQL) 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)

I have moved my web service based on WordPress from Windows to Linux server. Now, when I try to load one of the webpages, my nginx server reports

24 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function pg_connect()

One of the recommendation I found was to remove the semicolons (;) from php.ini and enable two extensions:

extension=pdo_pgsql
extension=pgsql

Unfortuanetly it caused additional warning in php initialisation that those libraries cannot be loaded because no requested files (pdo_pgsql, pdo_pgsql.so, pgsql and pgsql.so) exist.

Do you have any idea what to do to make my webpages visible again?

raj avatar
cn flag
raj
PHP extensions are usually delivered in separate packages from the main PHP package; you probably have to install `php-pgsql` package that will provide these files.
Darek avatar
us flag
Thanks @raj for your response. I have tried to install php7.4-pgsql but I received comment with unmet dependencies: php7.4-pgsql : Depends: php7.4-common (= 7.4.3-4ubuntu2.8) but 7.4.13-1+ubuntu18.04.1+deb.sury.org+1 is to be installed E: Unable to correct problems, you have held broken packages.
raj avatar
cn flag
raj
Seems that you have mixed up the repositories. `php7.4-pgsql` is probably going to be installed from standard Ubuntu repository, and your basic PHP packages have been probably installed from Ondrej Sury's repository which contains unofficial PHP ports. That repo seems to not contain `php-pgsql`, so you should uninstall the PHP packages you have installed, turn off that third-party repo and reinstall PHP from standard Ubuntu repositories. It's best to avoid use of third-party repositories unless absolutely necessary, as this may cause conflicts with system packages (which you experience).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.