32

Following all the instructions from UNIXMEN, installed postgresql-9.4 in CentOS 6.4. Everything went well, started the service and could access pgsql screen. But when I try to configure the phpPgAdmin, I couldn't find the files

  • postgresql.conf
  • pg_hba.conf
  • config.inc.php
  • phpPgAdmin.conf

The instructions says, postgresql home directory will sit in /etc/../ and some say it will be in /var/lib/. Where does the directory gets created (in CentOS)?

Is installation directory path is different in centos, redhat(RHEL7) & ubuntu?

Update: I ran a quick locate command for *postgresql.conf** and *hba.conf**, I found the sample files as postgresql.conf.sample and pg_hba.conf.sample (at /usr/pgsql-9.4/share/ )

  • 2
    Is there a postgres user? Can you try: sudo su - postgres? That will take you right to the postgres home directory and you should be able to locate the pg_hba.conf file...Usually in RHEL/CentOS it would be in /var/lib/psql/ or something of that nature... – ryekayo Oct 6 '15 at 17:45
  • awesome.. there it is, now I can see the files. But what is the reason that they didn't appear when I executed locate command?? @ryekayo – GIRI Oct 6 '15 at 17:48
  • that i'm not too sure of.. What was the command you did with locate? – ryekayo Oct 6 '15 at 18:08
  • locate .conf*/ *.conf / .conf were the command that I used. – GIRI Oct 6 '15 at 18:14
  • Well i would recommend using find for one, since you do have the file name...But if what i suggested solved your problem I will go ahead and add that as answer. – ryekayo Oct 6 '15 at 18:15
46

If you type the following:

sudo su - postgres

after installing postgresql-server, that should take you right to the home directory of postgres and will have the configuration files you are looking for. Usually in a RHEL environment, the configuration files would be stored in /var/lib/pgsql/. On my test environment it is stored in /var/lib/pgsql/9.1/data.

| improve this answer | |
  • 1
    Saved my day. It's working for postgres 9.2 – Rahal Kanishka Nov 7 '17 at 6:42
  • 1
    In CentOS 7.6.1810 version is ommitted: /var/lib/pgsql/data/postgresql.conf and postgres home folder falls one folder short: /var/lib/pgsql – Björn Sep 10 '19 at 9:26
6

Use linux command locate (Docs: http://man7.org/linux/man-pages/man1/locate.1.html)

[root@CENTOS7 pgsql]# locate pg_hba.conf
/usr/pgsql-10/share/pg_hba.conf.sample
/var/lib/pgsql/10/data/pg_hba.conf
| improve this answer | |
5

I am in CenOS 7, locate is not installed by default. Similar to the answer above, but run with show cmd below:

psql -U postgres -c 'show config_file'

And find the files are in /data/pgdata/postgresql.conf.

| improve this answer | |
1

Below query will help to find postgres configuration file.

postgres=# SHOW config_file;
             config_file
-------------------------------------
 /var/lib/pgsql/data/postgresql.conf
(1 row)

[root@node1 usr]# cd /var/lib/pgsql/data/
[root@node1 data]# ls -lrth
total 48K
-rw------- 1 postgres postgres    4 Nov 25 13:58 PG_VERSION
drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_twophase
drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_tblspc
drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_snapshots
drwx------ 2 postgres postgres    6 Nov 25 13:58 pg_serial
drwx------ 4 postgres postgres   36 Nov 25 13:58 pg_multixact
-rw------- 1 postgres postgres  20K Nov 25 13:58 postgresql.conf
-rw------- 1 postgres postgres 1.6K Nov 25 13:58 pg_ident.conf
-rw------- 1 postgres postgres 4.2K Nov 25 13:58 pg_hba.conf
drwx------ 3 postgres postgres   60 Nov 25 13:58 pg_xlog
drwx------ 2 postgres postgres   18 Nov 25 13:58 pg_subtrans
drwx------ 2 postgres postgres   18 Nov 25 13:58 pg_clog
drwx------ 5 postgres postgres   41 Nov 25 13:58 base
-rw------- 1 postgres postgres   92 Nov 25 14:00 postmaster.pid
drwx------ 2 postgres postgres   18 Nov 25 14:00 pg_notify
-rw------- 1 postgres postgres   57 Nov 25 14:00 postmaster.opts
drwx------ 2 postgres postgres   32 Nov 25 14:00 pg_log
drwx------ 2 postgres postgres 4.0K Nov 25 14:00 global
drwx------ 2 postgres postgres   25 Nov 25 14:20 pg_stat_tmp
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.