Installing Postgres PDO driver on cPanel

cPanel offers two options for installing PDO – using EasyApache which can enable PDO and MySQL’s PDO driver or installing everything via PECL. Unfortunately, under PHP 5.3, the PECL installers don’t work, so if you need any other PDO drivers, you’re in a hole.

Luckily, you can install it manually.

Download the PDO driver from the PECL website. Extract the archive and CD into the directory.

tar -xzf PDO-PGSQL-1.0.2.tgz
cd PDO-PSQL-1.0.2/

Once this is done, run the standard commands for building a PHP extension.

 ./configure --with-php-config=/usr/local/bin/php-config
make install

Once this is done, you can add the extension to php.ini.

cd /usr/local/lib/
vim php.ini

Finally, restart Apache and the Postgres driver should show up in your phpinfo() output.