0

I have fedora 21 and I want to access postgresql db using phpPgAdmin. To do it I have installed httpd and phppgadmin, postgresql too.
I can log with no problem to pgql using for example

psql -U learning -W template1

or

psql -W template1

but when I enter localhost/phpPgAdmin I cannot log in the diff between to log in attempts in

> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "POST /phpPgAdmin/redirect.php HTTP/1.1" 200 2268 "http://localhost/phpPgAdmin/redirect.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/browser.php HTTP/1.1" 200 3005 "http://localhost/phpPgAdmin/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/themes/default/global.css HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/libraries/js/jquery.js HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/xloadtree/xtree2.js HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/themes/global.css HTTP/1.1" 304 - "http://localhost/phpPgAdmin/themes/default/global.css" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/xloadtree/xloadtree2.js HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/title.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/Refresh.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/Servers.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/L.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/Loading.gif HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/I.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/servers.php?action=tree HTTP/1.1" 200 275 "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"
> 127.0.0.1 - - [04/Mar/2015:17:44:27 +0100] "GET /phpPgAdmin/images/themes/default/DisconnectedServer.png HTTP/1.1" 304 - "http://localhost/phpPgAdmin/browser.php" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0"

my /var/lib/pgsql/data/pg_hba.conf is

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
host    all             all             192.168.1.0/24          ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident

my /etc/phpPgAdmin/config.inc.php

$conf['extra_login_security'] = false;

this is as far as I found how to make it work, but I do not how to do it phpPgAdmin at fail log in tells me "Próba zalogowania nie powiodła się.", which probably is something like "Attemt to log in has failed"

localhost/phpMyAdmin works normally

Can I somehow get reason why I was not logged in? Wrong password, no server etc?

SOLUTION I have gone easy way, reinstalled fedora and now everything works, but that is actually not a solution :P

1 Answers1

0

Try this.

If this is your IP address range that is accessing your computer then change

host    all             all             192.168.1.0/24          ident

to this

host    all             all             192.168.1.0/24          trust

Reload Postgres after you change it. And see if you can login.

You may also need to enable networking by changing this in the postgres conf.

from

listen_addresses='localhost'

to

listen_addresses='*' 

Also be sure you have granted all the appropriate priviliges to the user to be able to access that database or any databases your are wanting to manage.

Edit:

It might be an SELinux issue. You can temporarily turn off SELinux for testing by using this command.

setenforce 0

Then test the login and see if it works. If it does work that means selinux is preventing access, you should run this command to allow httpd to continue to work after reboot.

setsebool -P httpd_can_network_connect_db 1
Panama Jack
  • 23,020
  • 10
  • 59
  • 90
  • where I can find listen_addresses='localhost' ? – Michał Piotr Stankiewicz Mar 04 '15 at 18:02
  • I believe it should be in `postgresql.conf`. and reload after changes. – Panama Jack Mar 04 '15 at 18:03
  • found it in /var/lib/pgsql/data/postgresql.conf, but already was listen_addresses='*' – Michał Piotr Stankiewicz Mar 04 '15 at 18:04
  • It should however work with pg_hba changes I mentioned first. Are you using a new database login or the default postgres user? – Panama Jack Mar 04 '15 at 18:05
  • Make sure you have granted all privilges to the database you are trying to access to the new user. Use postgres user to update permissions if you need to. – Panama Jack Mar 04 '15 at 18:17
  • @up2 i do not excaptly get it. I have 3 postgresql users: mstankiewicz, learning and postgres (2 first with password) and 3 system users: mstankiewicz, postgres and root (all with password). only databases existing are default (so probably template1 ...), I tried to log in using psql with all users and always success, but via localhost/phpPgAdmin none of them access. mstankiewicz and learning are new users to my localhost postgresql server – Michał Piotr Stankiewicz Mar 04 '15 at 18:23
  • Those users will not have access by default when there is no schema they are assigned permissions to. You will need to use postgres/root or give them access to template1 since that's the only one. You need to create a database with the user from psql and assign all privileges to it and then you'll be able to login as that user to that database with phppgadmin. Have a look here http://stackoverflow.com/a/10861320/330987 – Panama Jack Mar 04 '15 at 18:30
  • I have all privileges on database template1 to mstankiewicz, no result – Michał Piotr Stankiewicz Mar 04 '15 at 18:45
  • Do you have Selinux on e.g. enforcing? – Panama Jack Mar 04 '15 at 19:15
  • how to check it and do it? I am linux noob actually – Michał Piotr Stankiewicz Mar 04 '15 at 19:55
  • SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 29 – Michał Piotr Stankiewicz Mar 04 '15 at 19:57
  • Tried but does not seem to work. Maybe something in phpPgAdmin configuration? phpMyAdmin is working normally, same go for both mysql/psql programs – Michał Piotr Stankiewicz Mar 04 '15 at 20:31
  • Did you do all of what I have up there including pg_hba conf make sure it's your IP of your pc or at least in the range listed there and turning off selinux? Make sure you have restarted postgres and restart httpd for good measure. Otherwise I don't know what else to tell you. I've pretty much covered what's typically the causes of that. – Panama Jack Mar 04 '15 at 20:39
  • FYI I don't use phppgadmin myself, I prefer pgadmin as it's a client on the desktop. Like Heidisql is for mysql. Which works great. – Panama Jack Mar 04 '15 at 20:42