Search code examples
postgresqldebian

No config files after a PostgreSQL installation on Debian Stretch


I had installed postgresql and postgis on new Debian stable (Stretch 9) like I did it on Debian 8.

When I'm connecting as postgresql user, I had an error:

postgres@servername:~$ psql

psql: n'a pas pu se connecter au serveur : Aucun fichier ou dossier de ce type Le serveur est-il actif localement et accepte-t-il les connexions sur la socket Unix « /var/run/postgresql/.s.PGSQL.5432 » ?

Translation:

psql: cannot connect to server: No file or directory of this kind. Is the server locally activated and does it accept connection on Unix Socket « /var/run/postgresql/.s.PGSQL.5432 » ?

So, I would like to have a look on my config file, but /etc/postgresql directory is empty ! There is no pg_hba.conf and no postgresql.conf !

root@servername:/etc# locate pg_hba.conf
/usr/share/postgresql/9.6/pg_hba.conf.sample

What did I wrong when installing postgresql?

Here is the command that I have launch to install it:

# apt-get install apache2 php phppgadmin postgresql postgresql-client postgis

The service seems to be running:

root@servername:/etc# service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enable
   Active: active (exited) since Tue 2017-07-04 07:13:05 UTC; 2s ago
  Process: 6982 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 6982 (code=exited, status=0/SUCCESS)

juil. 04 07:13:05 cthedifference systemd[1]: Starting PostgreSQL RDBMS...
juil. 04 07:13:05 cthedifference systemd[1]: Started PostgreSQL RDBMS.

But I find no running process:

# ps -edf|grep postgres
root      7077   908  0 07:15 pts/0    00:00:00 grep postgres

Log directory /var/log/postgresql/ is empty.


Solution

  • To correctly install and configure postgresql follow the instructions of the official documentation debian:

    apt-get install postgresql postgresql-client
    

    The configuration files should be found under /etc/postgresql/9.6/main:

    # ls /etc/postgresql/9.6/main
    

    Sample output:

    environment  pg_hba.conf    postgresql.conf
    pg_ctl.conf  pg_ident.conf  start.conf