43

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/ )

5
  • 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, 2015 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, 2015 at 17:48
  • that i'm not too sure of.. What was the command you did with locate?
    – ryekayo
    Oct 6, 2015 at 18:08
  • locate .conf*/ *.conf / .conf were the command that I used.
    – GIRI
    Oct 6, 2015 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, 2015 at 18:15

7 Answers 7

62

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.

2
  • 1
    Saved my day. It's working for postgres 9.2 Nov 7, 2017 at 6:42
  • 2
    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, 2019 at 9:26
10

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.

1
  • in kubuntu v20.04 i used ``` sudo updatedb sudo locate pg_hba.conf ```
    – SL5net
    Jan 4, 2022 at 18:46
9

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
1
  • yes. in kubuntu v20.04 i used sudo updatedb and sudo locate pg_hba.conf
    – SL5net
    Jan 4, 2022 at 18:53
3

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
1

I'm on CentOS 7 and I had to run initdb to generate postgresql.conf (and other) files.

/usr/pgsql-11/bin/postgresql-11-setup initdb
0

I am also using CentOS7. For me, the command was:

$ su - postgres
$ su - postgres
$ psql postgres
# show config_file;
 /var/lib/pgsql/data/postgresql.conf
# \q
$ exit
$ exit
-1

you won't be able to find pg_hba.conf with the locate command because it is owned by postgres not root user. In my centos 7 pg_hba.conf was present at /var/lib/pgsql/12/data

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .