After installing postgres-9.3
via yum
in my CentOS 7
, its default configuration puts socket in /tmp
directory. I have httpd
(installed via yum
as well) which is by default managed by system.d
with PrivateTmp
option enabled. This means that any web application running on httpd
can't access /tmp
so connect to postgres
. I have changed postgres configuration so it should put its socket in /var/run/postgres
just like in Ubuntu
.
Now the problem is, that postgres
doesn't have enough privileges to write to /var/run
. My first though was to do just:
chown postgres:postgres /var/run/postgres
But /var/run
directory is cleaned after reboot so this won't work. My question is:
How to grant access to /var/run/postgres
for postgres
user in such a way that will persist reboots? I don't want to change socket location and I don't want to change httpd
's system.d
configuration. I just want postgres
to be able to write to /var/run/postgres
. Any help is much appreciated.
Best Answer
Are you sure the socket is only in
/tmp
on CentOS 7?Recent versions of Fedora have two copies of the socket, one in
/run/postgresql
(which is where/var/run/postgresql
is really located after links are resolved) which is the preferred version on modern systems, and one in/tmp
for legacy clients that expect to find it there.In any case if you do need to ensure the directory is created at boot then use a
tmpfiles.d
file, like/usr/lib/tmpfiles.d/postgresql.conf
which ships in Fedora and contains:d /var/run/postgresql 0755 postgres postgres -