[Featureserver] permission denied to postGIS

Brent Pedersen bpederse at gmail.com
Wed Aug 15 17:27:08 EDT 2007


in your pg_hba.conf, it's simplest to add something like:
local   all         all                               trust
which is sounds like you have.
then you can do:
bpederse at gian-33-009r:~$ sudo su postgres
postgres at gian-33-009r:/home/bpederse$ createdb test
CREATE DATABASE
postgres at gian-33-009r:/home/bpederse$ psql -d test
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
# NOTE: here is where you'd do: CREATE ROLE username LOGIN;
test=# GRANT ALL on DATABASE test to bpederse;
GRANT
test=# \q

then in your FeatureServer script, you likely have to use:
db = pscyopg2.connect("dbname=test user=bpederse")

otherwise it will think you are the apache user which doesnt have a ROLE.

of course, if your version of "bpederse" doesnt exist, then you should
add using:
http://www.postgresql.org/docs/8.2/interactive/sql-createuser.html
that way, it matters less what user the webserver is running as, you
can just specify the user in the dsn, and the pg_hba.conf entry
'trust's since you're local.

hope that helps.
-b



On 8/15/07, Ed Fialkowski <edfialk at gmail.com> wrote:
> Hey all, I'm revisiting an old brick wall I ran into with getting Feature
> Server to read from postGIS.  I was hoping to have a working example for a
> conference in September.  Maybe we'll have an epiphany.  I'll go ahead and
> say my unix and apache knowledge is mediocre.
>
> Here's my problem:
> An error occurred: could not connect to server: Permission denied
>  Is the server running locally and accepting
>
>  connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
>
>
>  File "./FeatureServer/Server.py", line 232, in cgiHandler
>  format, content = service.dispatchRequest( params, path_info, host,
> post_data, request_method, accepts )
>
>  File "./FeatureServer/Server.py", line 105, in dispatchRequest
>
>  datasource.begin()
>  File "./FeatureServer/DataSource/PostGIS.py", line 19, in
> begin
>  self.db = psycopg2.connect(self.dsn
> )
>
>
> I'm running Apache as root.  (I didn't set this up, but apparently it was a
> prepackaged Apache with RedHat and he had problems when not run as root).
> PostGIS *MUST* be started and accessed as "postgres".
> I have the entire FeatureServer directory running as "psotgres" user.
>
> [root at niceguy tmp]# ll .s.* -a
> srwxrwxrwx  1 postgres postgres  0 Aug 15 14:42 .s.PGSQL.5432
> -rwxrwxrwx  1 postgres postgres 28 Aug 15 14:42 .s.PGSQL.5432.lock
>
> This is the lock file, which has 777 permissions.
>
> When I try from command line as "root":
> >>> db = psycopg2.connect("dbname=test")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> psycopg2.OperationalError: FATAL:  role "root" does not exist
>
> When I try from command line as "postgres":
> [postgres at niceguy cgi-bin]$ python
> >>> import psycopg2
> >>> db = psycopg2.connect("dbname=test")
> >>> print db.status
> 1
>
> It looks (to me) like the python in FeatureServer is not getting executed as
> postgres, because it connects fine from the command-line.
>
> So, one question is: Has anyone gotten FeatureServer to read from postGIS?
> Would you mind telling me a bit about your setup (webserver, users, etc.).
>
> Other than that, anyone have any ideas?
> Thanks.
>  -Ed
>
> _______________________________________________
> Featureserver mailing list
> Featureserver at openlayers.org
> http://featureserver.org/mailman/listinfo/featureserver
>
>



More information about the Featureserver mailing list