X-Original-To: pgsql-www-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CA1DBD7E64 for ; Mon, 5 Sep 2005 06:03:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28247-06 for ; Mon, 5 Sep 2005 09:03:03 +0000 (GMT) Received: from rehuapila.uta.fi (rehuapila.uta.fi [153.1.1.45]) by svr1.postgresql.org (Postfix) with ESMTP id 30CF1D76F7 for ; Mon, 5 Sep 2005 06:03:03 -0300 (ADT) Received: from valkoapila.uta.fi (valkoapila.uta.fi [153.1.1.42]) by rehuapila.uta.fi (8.13.4/8.13.4) with ESMTP id j85934l8024695 for ; Mon, 5 Sep 2005 12:03:04 +0300 (EEST) Received: from apila.uta.fi (localhost [127.0.0.1]) by valkoapila.uta.fi (8.13.4/8.13.4) with ESMTP id j85932xX001701 for ; Mon, 5 Sep 2005 12:03:02 +0300 Received: from peippi.uta.fi (peippi.uta.fi [153.1.6.44]) by apila.uta.fi (8.13.4/8.13.4) with ESMTP id j85932P1010135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 5 Sep 2005 12:03:02 +0300 (EEST) Received: from peippi.uta.fi (localhost.localdomain [127.0.0.1]) by peippi.uta.fi (8.13.4/8.13.4/Debian-3) with ESMTP id j85932ik008840 for ; Mon, 5 Sep 2005 12:03:02 +0300 Received: (from wwwroot@localhost) by peippi.uta.fi (8.13.4/8.13.4/Submit) id j85932W9008839 for pgsql-www@postgresql.org; Mon, 5 Sep 2005 12:03:02 +0300 Received: from kielipc032.uta.fi (kielipc032.uta.fi [153.1.33.102]) by imp2.uta.fi (Horde MIME library) with HTTP; Mon, 05 Sep 2005 12:03:02 +0300 Message-ID: <20050905120302.ol9od3acr3s0kso0@imp2.uta.fi> Date: Mon, 05 Sep 2005 12:03:02 +0300 From: Mihail Mihailov To: pgsql-www@postgresql.org Subject: Problems with connecting to PostgreSql database via web server MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0.4-cvs) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (apila.uta.fi [153.1.1.41]); Mon, 05 Sep 2005 12:03:02 +0300 (EEST) X-Scanned-By: MIMEDefang 2.52 on 153.1.1.42 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/4 X-Sequence-Number: 8518 Hello, I'm trying to connect to a PostgreSql database at the localhost using Apache 2.0 server. I'm working with Fedora Core 4. The cgi script is written in Python 2.4, I am using the PyGreSql library. The script works fine when started from command line, but when I start it via localhost I get the message: could not create socket: Permission denied Details: 1. I created the user 'www' and granted him select privilege on the table to access 2. I edited the httpd.conf, added "User www" 3. The script looks like this ********* #!/usr/bin/python2.4 import cgi import cgitb; cgitb.enable() import pgdb print "Content-Type: text/html" # HTML is following print # blank line, end of headers print "CGI script output" print "

This is my first CGI script

" print "Hello, world!" con = pgdb.connect(host = 'localhost', database= 'words',user = 'www', password = '') cursor = con.cursor() select = "select * from main;" cursor.execute(select) data = cursor.fetchall() for i in data: print i ************ 4. When I start it from the apache server, I get the following: ******************** InternalError Python 2.4.1: /usr/bin/python2.4 Sun Sep 4 23:41:18 2005 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. /var/www/cgi-bin/test.py 9 print "

This is my first CGI script

" 10 print "Hello, world!" 11 con = pgdb.connect(host = 'localhost', database= 'words',user = 'www', password = '') 12 cursor = con.cursor() 13 select = "select * from main;" con undefined, pgdb = , pgdb.connect = , host undefined, database undefined, user undefined, password undefined /usr/lib/python2.4/site-packages/pgdb.py in connect(dsn=None, user='www', password='', host='localhost', database='words') 369 # open the connection 370 cnx = _connect_(dbbase, dbhost, dbport, dbopt, 371 dbtty, dbuser, dbpasswd) 372 return pgdbCnx(cnx) 373 dbtty = '', dbuser = 'www', dbpasswd = '' InternalError: could not create socket: Permission denied args = ('could not create socket: Permission denied\n',) ************ 5. The previous experiments with granting privileges to public and to user apache led to the same result. What is wrong? Thanks in advance. Mihail Mihailov