Re: [GENERAL] How to configure PostgreSQL for PHP access & postgresadmin

From: Louis Bertrand <louis(at)bertrandtech(dot)on(dot)ca>
To: Hans Rakers <hans(at)clubned(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] How to configure PostgreSQL for PHP access & postgresadmin
Date: 2000-03-05 03:31:06
Message-ID: Pine.BSO.4.20.0003042207480.5165-100000@grendel.bts
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Not sure if this was answered.I've been rather quick with the delete key
lately (oops).

I'm replying from memory, I went through the exercise a while back and I
can't find my notes. It sounds like you have not initialised the
PostgreSQL database directory. You need to run the "initdb" command. Do it
as the PostgreSQL pseudo-user to make sure the permissions are correct.
Then you'll need to create users with the createuser script. PostgreSQL's
users are not the same as UNIX users (although they can have the same user
ID, that's just a mnemonic convenience).

To become a given PostgreSQL user, just set the environment variable
PGUSER to the name of the PostgreSQL user.

As for security, you have several decisions to make: if you're only ever
accessing PGSQL from the local machine (e.g. your Apache setup), don't
start the postmaster with -i option. This means it will only ever accept
connections from the local machine, not the network. If you are allowing
remote access, you need to set up /var/pgsql/data/pg_hba.conf for
system+user privileges. The system table pg_user lists the users. You can
list it with: select * from pg_user; For additional peace of mind, you
can also set up packet filtering (Linux IPchains, BSD IPF) on port 5432 to
eliminate obvious shenanigans.

BTW, I'm not sure it's wise to run Apache as user nobody. You should
create a dedicated pseudo user and group for the Apache, e.g. user www,
group www. There is a setting in the httpd_conf file.

After that, assuming you've created whatever database and tables you need,
PHP3 should connect just fine with pg_connect().

Ciao
--Louis <louis(at)bertrandtech(dot)on(dot)ca>

Louis Bertrand http://www.bertrandtech.on.ca/
Bertrand Technical Services, Bowmanville, ON, Canada

OpenBSD: Secure by default. http://www.openbsd.org/

On Fri, 3 Mar 2000, Hans Rakers wrote:

>
> Hello all,
>
> After getting crazy about the fact that MySQL does not support
> subqueries, i decided to give it a go with PostgreSQL. Compiling and
> installing went fine, but i'm having trouble understanding the database
> user and security concepts that PostgreSQL uses.
>
> Can any of you tell me how i configure PostgreSQL for access by PHP? I
> have PHP compiled as a Apache module (with pgsql support ofcourse), and
> Apache runs under nobody:nogroup. What needs to be done to be able to
> use pgsql via PHP with regards to what users need to be added, what
> files need editing and how to make the whole thing secure?
>
> Also i'm having trouble using postgresadmin from www.phpwizard.net. It
> displays the following error:
>
> --
> Warning: Unable to connect to PostgresSQL server: FATAL 1: Database
> dbname=template1 does not exist in pg_database in lib.inc.php3 on line
> 125
> --
>
> Although the database template1 does exist when loging in as the
> postgres superuser and executing 'psql template1'. Am i doing anything
> wrong here??
>
> Any help would be greatly appreciated.
>
> Thanks in advance,
>
> Hans Rakers
>
> --
> ---------------------------------------------------------------------
> Hans Rakers (hans(at)clubned(dot)com) Tel: +31 (0)20-4490485
> System engineer / Webmaster / Webdeveloper Fax: +31 (0)20-4490495
> ClubNed - TeKoop http://www.clubned.com
> Badhoevedorp, the Netherlands http://www.tekoop.nl
>
>
> ************
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed Loehr 2000-03-05 03:35:39 Re: [GENERAL] RE: Help with installing 6.5.3 on RedHat6.1 - specifying template
Previous Message Chris Carbaugh 2000-03-05 02:11:12 RE: Help with installing 6.5.3 on RedHat6.1 - specifying template