Re: Unable to connect to PostgreSQL Server: Permission denied

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Perhaps you or your host are running SE Linux??  Depending on your
configuration, users may be forced to run personal websites out of their
home directories.

Cameron

+++++++++++++++++++++++++++++++++++++
Cameron G. Moller,  Senior Officer
Technical Project Manager
SSGM Infrastructure
State Street Corporation                       ...   __o
Cell:  617-799-9049                               ...    -\<,
Desk:  617-664-4501                            ... (_)/(_) ..
+++++++++++++++++++++++++++++++++++++


                                                                           
             "muralidhar                                                   
             sortur"                                                       
             <sorturmuralidhar                                          To 
             @rediffmail.com>          "Javier Carlos"                     
             Sent by:                  <nediam@xxxxxxxxxxxxx>, "Gnanavel   
             pgsql-php-owner@p         S" <s.gnanavel@xxxxxxxxx>,          
             ostgresql.org             "pgsql_php"                         
                                       <pgsql-php@xxxxxxxxxxxxxx>          
                                                                        cc 
             04/04/2006 09:46                                              
             AM                                                    Subject 
                                       Re: [PHP] Unable to connect to      
                                       PostgreSQL Server: Permission       
             Please respond to         denied                              
                "muralidhar                                                
                  sortur"                                                  
             <sorturmuralidhar                                             
             @rediffmail.com>                                              
                                                                           
                                                                           





Hi ,
in my last mail i forgot to mention that i have restarted apache server
after making changes to the httpd.conf.

Today i made one more experiment ...

1. changed httpd.conf

    user apache
    Group apache

    DocumentRoot="/home/murali/html"

    <DocumentRoot "/home/murali/html">
    ......(as it is)....
    <DocumentRoot>

2. copied the files add.html and add-entry.html to directory html under my
home directory i.e

/home/murali/html

3. restarted apache
/usr/sbin/apachectl start ( from root)

4. from postgres login started postmaster.

postmaster -i -D data&

5. http://localhost/add.html ( entered Name , Phone , Email)

EVERY THING WORKED !!!!!

BUT CAN ANY ONE TELL ME, WHAT WAS THE PROBLEM WITH EARLIER SETTING AND WHAT
MADE IT TO WORK PROPERLY NOW !!! I NEED TO ANSWER THESE QUESTIONS


Thanks for all of your help
regards
Muralidhar

On Tue, 04 Apr 2006 Javier Carlos wrote :
>  Did you try to restart the PosgreSQL server using pg_ctl ?
>
>$ pg_ctl restart
>
>
>    Are you able to connect as user from the command line?
>
>$ psql AddressBook www
>
>  Regards,
>
>  Javier
>
>
> >
> > Hi ,
> > Here is the complete description of the problem ...
> >
> > I have newly installed fedora core 4 with option as everyting.
> >
> > it comes with apache webserver, postgresql , php-postgresql, php-gd
etc,
> >
> > it creates a default user postgres with home = /var/lib/psql
> >
> > 1. i loged in as postgres
> >
> > 2. called initdb
> >  created database under directory ~/data
> >
> > 3. changed postgresql.conf to include
> >      listen_addresses = '*'
> >      port = 5432
> >
> > 4. changed pg_hba.conf
> >      local  all  all                        trust
> >      host    all  all  127.0.0.1/32        trust
> >      host    all  all  192.168.1.18/24      trust
> >      host    all  all        ::1/128        trust
> >
> > 5. postmaster -i -D ~/data &
> >
> > 6. createdb AddressBook
> >
> > 7. psql AddressBook
> >
> > 8. create table addresses( Name text, Phone text, Email text);
> >
> > 9. create user www NOCREATEDB NOCREATEUSER;
> >
> > 10. grant all on addresses to www;
> >
> > 11. from other terminal i loged in as root
> >
> > 12. changed /etc/httpd/conf/httpd.conf
> >
> >    User www
> >    Group postgres
> >
> > 13. copied add.html and add-entry.php into directory /var/www/html
> >
> > add.html
> > ------------------------------------------------------
> > <HTML>
> > <BODY>
> >
> > <FORM ACTION="add-entry.php" METHOD="GET">
> >
> > <TABLE BORDER=1>
> >  <TR>
> >  <TD>
> >  <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2>
> >    <TR>
> >    <TD>Name</TD>
> >    <TD><INPUT TYPE="TEXT" NAME="Name" VALUE=""></TD>
> >    </TR>
> >    <TR>
> >    <TD>Phone</TD>
> >    <TD><INPUT TYPE="TEXT" NAME="Phone" VALUE=""></TD>
> >    </TR>
> >    <TR>
> >    <TD>E-mail</TD>
> >    <TD><INPUT TYPE="TEXT" NAME="Email" VALUE=""></TD>
> >    </TR>
> >    <TR>
> >    <TD COLSPAN=2 ALIGN=CENTER>
> >      <INPUT TYPE="SUBMIT" VALUE="Add Entry">
> >    </TD>
> >    </TR>
> >  </TABLE>
> >  </TD>
> >  </TR>
> > </TABLE>
> > </FORM>
> >
> > </BODY>
> > </HTML>
> > --------------------------------------------------
> > add-entry.php
> > --------------------------------------------------
> >
> > <HTML>
> > <BODY>
> > <?PHP
> > $db = pg_Connect( "dbname=AddressBook user=www");
> > if( !$db )
> > {
> >  echo "Could not connect!";
> >  exit;
> > }
> >
> > $Name=$_GET['Name'];
> > $Email=$_GET['Email'];
> > $Phone=$_GET['Phone'];
> >
> > $query = "INSERT INTO Addresses VALUES( '$Name', '$Phone', '$Email'
);";
> >
> > $result = pg_Exec( $db, $query );
> >
> > if( !$result )
> > {
> >  echo "No result set returned!";
> >  exit;
> > }
> >
> > $rows = pg_NumRows( $result );
> >
> > if( $rows = 0 )
> > {
> >  echo "Add Failed.";
> >  exit;
> > }
> >
> > $query = "SELECT * FROM Addresses WHERE \"Name\" = '$Name';";
> >
> > $query = "SELECT * FROM Addresses WHERE \"Name\" = '$Name';";
> >
> > $result = pg_Exec( $db, $query );
> > $row = pg_Fetch_Row( $result, 0 );
> >
> > $nameResult = $row[0];
> > $phoneResult = $row[1];
> > $emailResult = $row[2];
> >
> > echo "Name = $nameResult<BR>";
> > echo "Phone = $phoneResult<BR>";
> > echo "E-mail = $emailResult<BR>";
> >
> > pg_Close( $db );
> > ?>
> >
> > <H3>Add Okay!</H3>
> >
> > </BODY>
> > </HTML>
> > -------------------------------------------------------------
> > Error i get is
> > Mon Apr 03 18:39:53 2006] [notice] Apache/2.0.54 (Fedora) configured --
> > resuming normal operations
> > [Mon Apr 03 18:42:17 2006] [error] [client 127.0.0.1] File does not
exist:
> > /var/www/html/favicon.ico
> > [client 127.0.0.1] PHP Warning:  pg_connect() [<a
> > href='function.pg-connect'>function.pg-connect</a>]: Unable to connect
to
> > PostgreSQL server: could not connect to server: Permission denied\n\tIs
> > the server running locally and accepting\n\tconnections on Unix domain
> > socket "/tmp/.s.PGSQL.5432"? in /var/www/html/add-entry.php on
> > line 5, referer: http://localhost/add.html
> > [Mon Apr 03 18:42:22 2006] [error] [client 127.0.0.1] File does not
exist:
> > /var/www/html/favicon.ico
> >
> > _______________________________________________________
> >
> > from the command line it works fine
> > i.e php add-entry.php works fine ( ofcourse adds an empty row into the
> > data base)
> >
> > --------------------------------------------------
> >
> > i did telnet
> >
> > [root@localhost html]# telnet localhost 5432
> > Trying 127.0.0.1...
> > Connected to localhost.localdomain (127.0.0.1).
> > Escape character is '^]'.
> >
> >
> > Connection closed by foreign host.
> >
> > data/pg_log/postgresql-Mon.log contains
> >
> > LOG:  invalid length of startup packet
> >
> >
> >
> > -------------------------------
> >
> >
> > I am not getting any clue as to how to solve this problem ...let me
know
> > if you have any idea in solving this porblem.
> >
> > regards
> > Muralidhar
> >
> >
> >
>
>
>
>-------------
>nediam.com.mx
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: don't forget to increase your free space map settings




(Embedded image moved to file: pic14604.gif)

Attachment: pic14604.gif
Description: GIF image


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux