Re: [GENERAL] Unable to connect to Postgresql - Mailing list pgsql-general

From John Iliffe
Subject Re: [GENERAL] Unable to connect to Postgresql
Date
Msg-id 201704101109.40555.john.iliffe@iliffe.ca
Whole thread Raw
In response to Re: [GENERAL] Unable to connect to Postgresql  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-general
On Monday 10 April 2017 09:46:54 Daniel Verite wrote:
>     John Iliffe wrote:
> > Based on the reference that Joe sent earlier, I do have a second
> > domain socket on /var/pgsql but the problem is how do I get PHP to
> > look there?
>
>   pg_connect("host=/var/pgsql [...other parameters...]")
>
> The fact that the value for host starts with a slash indicates
> without ambiguity that it's a path on disk rather than the name
> or address of a host on the network.
>
> However if apache runs in a chroot jail, it should no more see
> /var/pgsql than it sees /tmp
> Given an apache process id, on Linux you should be able
> to check the current filesystem-root of that process with
> # ls -ld /proc/$PID/root
> It should show a soft link to the directory that corresponds to
> the root from the point of view of the $PID process.
>
You are exceeding my level of understanding of Linux but the following
result suggests to me that Apache is using the common root directory (/) as
its base.

-------------------------------------
[root@prod04 John]# ls -ld /proc/27753/root
lrwxrwxrwx. 1 root root 0 Apr 10 10:52 /proc/27753/root -> /
--------------------------------------

Other than the rather odd requirement in the systemctl unit file that httpd
has a private /tmp (see arrow below) there should be no reason why Apache
can't see the /tmp directory.  One of the earlier references in this series
mentioned I should check for that, which is the reason for the secondary
socket on /var/pgsql/  .  I don't know how to make mod_php, or for that
matter php-fpm, look for the Postgresql socket on /var/pgsql/ though.
There is no conf file for mod_php and no directive that I can find in the
php-fpm configuration file.

--------------------------------
[root@prod04 John]# cat /etc/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server

[Service]
Type=forking
EnvironmentFile=/usr/apache-2.4.25/bin/envvars
PIDFile=/var/run/httpd.pid
ExecStart=/usr/apache-2.4.25/bin/apachectl -k start
ExecReload=/usr/apache-2.4.25/bin/apachectl -k graceful
ExecStop=/usr/apache-2.4.25/bin/apachectl -k stop
KillSignal=SIGCONT
PrivateTmp=true        <-----------

[Install]
WantedBy=multi-user.target

--------------------------------

FYI, changing the PrivateTmp directive to false doesn't fix the problem and
since I don't know why it is there I don't ant to touch it.

> But again, most people would use host=localhost in this setup.
>
> Best regards,


pgsql-general by date:

Previous
From: John Iliffe
Date:
Subject: Re: [GENERAL] Unable to connect to Postgresql
Next
From: John Iliffe
Date:
Subject: Re: [GENERAL] Unable to connect to Postgresql