Re: Unable to connect to Postgresql

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "John Iliffe" <john(dot)iliffe(at)iliffe(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org,"Adrian Klaver" <adrian(dot)klaver(at)aklaver(dot)com>,"Joe Conway" <mail(at)joeconway(dot)com>
Subject: Re: Unable to connect to Postgresql
Date: 2017-04-10 22:01:44
Message-ID: 50e94bc7-7260-4fff-83dc-fb69f235db7a@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Iliffe wrote:

> Yes, I will do that, but there are several hundred PHP web page scripts to
> be updated. Presumably if one script opens two different databases then
> both of the pg_connect() instances will need to be updated.

If you have many calls to pg_connect() without a host
in the connect string, meaning it defaults to /tmp, instead of
changing them you may inject a PGHOST variable into the Apache
environment with /var/pgsql as the value. This will make it
the default host, so basically everything that was going
implicitly to /tmp will go to /var/pgsql instead.
I think in RedHat the definition should go into /etc/sysconfig/httpd

Generally the environment variables described for libpq here:
https://www.postgresql.org/docs/9.6/static/libpq-envars.html
apply to php's pg_connect() as well, since it's really just
a thin wrapper on top of libpq's PQconnectdb().

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

In response to

Browse pgsql-general by date

  From Date Subject
Next Message rob stone 2017-04-10 23:06:46 Re: Unable to connect to Postgresql
Previous Message Adrian Klaver 2017-04-10 20:58:46 Re: Unable to connect to Postgresql