All HowTo's PostgreSQL

cPanel overwriting my pg_hba.conf file

This article describes and solves (work-around) a problems with PostgreSQL and cPanel. The issue is that cPanel modifies the file “/var/lib/pgsql/9.4/data/pg_hba.conf” setting it back to a default state.

This article has more information: http://www.davidghedini.com/pg/entry/installing_postgresql_9_on_cpanel

By setting that file to your liking such as the following:

local all  all        md5
host samerole all  127.0.0.200   255.255.255.255   pam  pamservice=postgresql_cpses
host all all  127.0.0.1   255.255.255.255   md5
local all postgres        md5
host all postgres  127.0.0.1   255.255.255.255   md5

And setting it’s permissions to read-only:

chattr -ia /var/lib/pgsql/9.4/data/pg_hba.conf

If you need to make future changes to the above file, first reset it’s permissions using the following:

chattr +ia /var/lib/pgsql/9.4/data/pg_hba.conf

You should be able to move on without cPanel tripping you over in future.

You’ll need to restart PostgreSQL:

/etc/init.d/postgresql-9.4 status
/etc/init.d/postgresql-9.4 restart

One comment

Leave a Reply to S Shorter Cancel reply

Your email address will not be published. Required fields are marked *