How to install pdo_pgsql on cPanel server

When you try to install PHP Pecl module PDO_PGSQL, through WHM by going to Home »Software »Module Installers, you might be presented with the following error:

compilation terminated.
make: *** [pdo_pgsql.lo] Error 1
ERROR: `make' failed
The PDO_PGSQL.so object is not in /usr/local/lib/php/extensions/no-debug-non-zts-20131226
Tidying /usr/local/cpanel/3rdparty/php/56/etc/php.ini...
No changes
Tidying /usr/local/lib/php.ini...
 Skipping duplicate extension: pdo_pgsql.so
Wrote changes

You might also get a similar error when trying to install pdo_pgsql through shell with pecl install pdo_pgsql.

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /root/tmp/pear/pear-build-roottXvx5k/PDO_PGSQL-1.0.2/libtool --mode=compile cc -I  -I. -I/root/tmp/pear/PDO_PGSQL -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-roottXvx5k/PDO_PGSQL-1.0.2/include -I/root/tmp/pear/pear-build-roottXvx5k/PDO_PGSQL-1.0.2/main
-I/root/tmp/pear/PDO_PGSQL -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/tmp/pear/PDO_PGSQL/pdo_pgsql.c -o pdo_pgsql.lo
mkdir .libs
 cc -I -I. -I/root/tmp/pear/PDO_PGSQL -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-roottXvx5k/PDO_PGSQL-1.0.2/include -I/root/tmp/pear/pear-build-roottXvx5k/PDO_PGSQL-1.0.2/main -I/root/tmp/pear/PDO_PGSQL -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/PDO_PGSQL/pdo_pgsql.c  -fPIC -DPIC -o .libs/pdo_pgsql.o
/root/tmp/pear/PDO_PGSQL/pdo_pgsql.c:22:20: fatal error: config.h: No such file or directory
 #include "config.h"
                    ^
compilation terminated.
make: *** [pdo_pgsql.lo] Error 1
ERROR: `make' failed

You can install pdo_pgsql by downloading and compiling it manually using following set of commands:

wget http://pecl.php.net/get/PDO_PGSQL-1.0.2.tgz
tar -xzf PDO_PGSQL-1.0.2.tgz
cd PDO_PGSQL-1.0.2/
phpize
./configure
make && make install
echo "extension=pdo_pgsql.so" >> /usr/local/lib/php.ini
Reference:

https://forums.cpanel.net/threads/unable-to-install-pdo_pgsql.554271/

Leave a Reply