Wednesday, June 5, 2013

Install PostgreSQL 9.2 with cPanel/WHM on CentOS Linux

While cPanel still only officially supports PostgreSQL as provided by the CentOS repo's, the following is a fool proof method for fully integrating PostgreSQL 9.2 into cPanel/WHM on CentOS without any issues.

Note: This was performed on a vanilla CentOS 6.4 installation with cPanel/WHM 11.36.1 (build 6)

Step 1: Grab the correct PostgreSQL 9.2 rpm pacakge for your Linux distribution from:
http://yum.postgresql.org/repopackages.php#pg92

...and then install it
[/usr/local/src]# wget http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
[/usr/local/src]# rpm -i pgdg-centos92-9.2-6.noarch.rpm 
Step 2: Install the PostgreSQL 9.2 software:
[/usr/local/src]# yum groupinstall "PostgreSQL Database Server PGDG" -y 
[/usr/local/src]# yum install postgresql92-devel.x86_64 -y 
Step 3: Initialize the PostgreSQL 9.2 database:
[/usr/local/src]# service postgresql-9.2 initdb
Step 4: Start PostgreSQL 9.2 on boot:
[/usr/local/src]# chkconfig postgresql-9.2 on
Step 5: Create the proper symlinks for cPanel/WHM integration:
[/usr/local/src]# cd /usr/pgsql-9.2/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
[/usr/local/src]# cd /var/lib/pgsql; ln -s 9.2/backups; ln -s 9.2/data; ln -s 9.2/pgstartup.log
[/usr/local/src]# cd /usr/pgsql-9.2/lib; ln -s libpq.so.5.5 libpq.so
Step 6: Start the PostgreSQL 9.2 server:
[/usr/local/src]# service postgresql-9.2 start
Step 7: Install the PostgreSQL 9.2 cPanel/WHM config:

-Log into cPanel/WHM as root
-Navigate to "Home > SQL Services > Configure PostgreSQL"
-Click on "Install config"

Step 8: Install/update phpPgAdmin:
[/usr/local/src]# /usr/local/cpanel/bin/updatephppgadmin --force
Step 9: Exclude PostgreSQL from yum:

You'll want to add "exclude=postgres*" to the [base] and [updates] section of this file:
[/usr/local/src]# vi /etc/yum.repos.d/CentOS-Base.repo
...this will prevent yum from accidentally installing the repo version of PostgreSQL in the future.

That's all there is to it =) Now you can enjoy full, native integration without any fuss

No comments:

Post a Comment