public inbox for [email protected]  
help / color / mirror / Atom feed
From: Mihail Mihailov <[email protected]>
To: [email protected]
Subject: Problems with connecting to PostgreSql database via web server
Date: Mon, 05 Sep 2005 12:03:02 +0300
Message-ID: <[email protected]> (raw)

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 
"<TITLE>CGI script output</TITLE>" print "<H1>This is my first CGI 
script</H1>" 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 "<H1>This is my first CGI script</H1>" 
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 = <module 'pgdb' 
from '/usr/lib/python2.4/site-packages/pgdb.pyc'>, pgdb.connect = 
<function 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




reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Problems with connecting to PostgreSql database via web server
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox