Running DigitalOcean Droplet on Ubuntu (20.4?)
My user A has root permissions. They are also connected to userA in the postgres database.
Due to the setup of the software I'm using, they require a specific username for postgresdb. To avoid exposing too much data online, we'll call it userB. This is both a linux and postgres user.
I'm running a php command that basically takes (uname,dbname,pdo,options) as input, but it's currently failing because it can't find the pdo file.
I browsed some posts. Someone suggested uncommenting all pgsql and pdo_pgsql lines in all php.ini files, which I have done, whether for production, development or the general purpose version of the file.
I get this error when I run the command as userA and userB.
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0
However, pdo_pgsql.so does actually exist in that location. (Is it looking for a file named pdo_pgsql but pdo_pgsql.so?)
php website says to run a
./configure
command, but it doesn't really say in which folder configure is located. It's not a package I can install from the cli. (https://www.php.net/manual/en/ref.pdo-pgsql.php)
Other pages say you have to install autoconf first (https://unix.stackexchange.com/questions/158960/can-not-run-configure-command-no-such-file-or-directory), but this has Not produced. /Configure a usable command for me.
I also found an article saying that the conf file in apache needs to be updated to show the location of the PDO file, but I don't have the server running yet, I just run a php file that populates the local pgsql database. (pgsql extension not loaded)
running
php -i | grep PDO
given
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0 PDO PDO support => enabled PDO drivers => pgsql PDO Driver for PostgreSQL => enabled
Although according to the API's customer service, it should return
PDO PDO support => enabled PDO drivers => mysql, odbc, pgsql PDO Driver for MySQL => enabled PDO Driver for ODBC (unixODBC) => enabled PDO Driver for PostgreSQL => enabled
Although I think they give multiple examples of different drivers depending on the database software you choose.
I'm not quite sure what to do.
renew:
I tried by editing the php.ini file used by php
php -i | grep ini
I used it
locate pdo_pgsql
Find the pdo_pgsql and pdo_pgsql.so file paths. I have tried 4 different edits to the php.ini file. 2 Uncomment (one at a time) the default pgsql extensions. 2 are different file paths to the pdo_pgsql file found on my system via locate.
**extension=/usr/lib/php/20190902/pdo_pgsql.so** sudo php file.php PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20190902/pdo_pgsql.so' (tried: /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: **undefined symbol: pdo_parse_params**), /usr/lib/php/20190902//usr/lib/php/20190902/pdo_pgsql.so.so (/usr/lib/php/20190902//usr/lib/php/20190902/pdo_pgsql.so.so: **cannot open shared object file: No such file or directory**)) in Unknown on line 0 **extension=/var/lib/php/modules/7.4/registry/pdo_pgsql** sudo php file.php PHP Warning: PHP Startup: Unable to load dynamic library '/var/lib/php/modules/7.4/registry/pdo_pgsql' (tried: /var/lib/php/modules/7.4/registry/pdo_pgsql (/var/lib/php/modules/7.4/registry/pdo_pgsql: **file too short**), /usr/lib/php/20190902//var/lib/php/modules/7.4/registry/pdo_pgsql.so (/usr/lib/php/20190902//var/lib/php/modules/7.4/registry/pdo_pgsql.so: **cannot open shared object file: No such file or directory)**) in Unknown on line 0 Could not open input file: file.php **extension=pgsql** sudo php file.php **PHP Warning: Module 'pgsql' already loaded in Unknown on line 0** Could not open input file: file.php **extension=pdo_pgsql** sudo php file.php PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: **cannot open shared object file: No such file or directory**), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: **undefined symbol: pdo_parse_params**)) in Unknown on line 0 Could not open input file: file.php
Output according to the following user requirements
$ php -v PHP 7.4.3 (cli) (built: Mar 2 2022 15:36:52) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies $ dpkg -l|grep pgsql ii php-pgsql 2:7.4+75 all PostgreSQL module for PHP [default] ii php7.4-pgsql 7.4.3-4ubuntu2.10 amd64 PostgreSQL module for PHP $ dpkg -l|grep php ii php-common 2:75 all Common files for PHP packages ii php-pgsql 2:7.4+75 all PostgreSQL module for PHP [default] ii php7.4-cli 7.4.3-4ubuntu2.10 amd64 command-line interpreter for the PHP scripting language ii php7.4-common 7.4.3-4ubuntu2.10 amd64 documentation, examples and common module for PHP ii php7.4-json 7.4.3-4ubuntu2.10 amd64 JSON module for PHP ii php7.4-opcache 7.4.3-4ubuntu2.10 amd64 Zend OpCache module for PHP ii php7.4-pgsql 7.4.3-4ubuntu2.10 amd64 PostgreSQL module for PHP ii php7.4-readline 7.4.3-4ubuntu2.10 amd64
If something doesn't work on your DEV enc, don't try it on PROD..that defeats the purpose of having a DEV env..
In
php.ini
you should already have an example of how to enable pgsql:is not
module=
I don't know what your PHP version is, but please make sure you have the appropriate version of
php7.X-pgsql
installed as you seem to have the wrong library version.You might be able to add the following output to your question: