- gustavo's personal blog

Installing PostgreSQL 9.4 on CentOS 6 with cPanel 11

cPanel’s support for PostgreSQL is notably bad, but it’s easy to work around the existing limitations and to install the latest shiny release of Postgres (currently 9.4, with jsonb support!).

First, you need to add the Postgres repository to your system. You can find the link to the latest RPM file on Postgres website.

rpm -Uvh

Then, install it using yum:

yum install postgresql94-server postgresql94

When the installation completes, you’ll need to run the setup script and enable the Postgres service:

/usr/pgsql-9.4/bin/postgresql94-setup initdb
chkconfig postgresql-9.4 on

You’ll also need to setup the symlinks for Postgres to work with the cPanel/WHM hooks:

cd /usr/pgsql-9.4/bin/; for f in *; do echo $f; [ -e /usr/bin/$f ] && mv /usr/bin/$f /usr/bin/$f.8; ln -s $(pwd)/$f /usr/bin/$f; done
cd /var/lib/pgsql; ln -s 9.4/backups; ln -s 9.4/data; ln -s 9.4/pgstartup.log

If you want to install phpPgAdmin, you will need to run cPanel’s installation script:


Finally, log into WHM and go to Configure PostgreSQL. Click on Install Config, wait, click on Create Users, wait and then reboot your server. Voilà!

![cPanel PostgreSQL setup]({{ site.url }}/images/cpanel-postgres.png)