标签: phpPgAdmin

  • phpPgAdmin连接postgresql数据库的配置 CentOS6_64bit

    phpPgAdmin是Postgresql的图形化操作界面,但是很多ITGeeker往往在安装的时候很难一次性成功,根据多次实践,技术奇客在此与大家分享实战经验,此案例以postgresql9.3版本为例。

     

    确认一下是否已安装Postgresql数据库并启动:

    netstat -lnp|grep 5432

    1. 安装图形客户端phppgadmin

    yum install phpPgAdmin

    如果没有,安装一下EPEL源吧

    yum install epel-release

     

    2. phpPgAdmin.conf配置

    vi /etc/httpd/conf.d/phpPgAdmin.conf

    Alias /phpPgAdmin /usr/share/phpPgAdmin
    
    <Location /phpPgAdmin>
        Order allow,deny
    #   Deny from all
        Allow from all
    #   Allow from 127.0.0.1
        Allow from ::1
    # Allow from .example.com
    </Location>

    把Allow from改为客户端的ip地址或者本地127.0.0.1(安全性更好),或者改为Allow from all也可。

    3. pg_hba.conf配置

    vi /var/lib/pgsql/9.3/data/pg_hba.conf
    主要修改ipv4部分内容,都改成trust,这样最省事。

    # IPv4 local connections:
    host all all 127.0.0.1/32        trust
    host all all your IP/24          trust
    host all all your company IP/24  trust

    可以只添加公司的公网ip和自己家里的ip地址,这样比较安全。

    修改认证方式,将md5改为trust,然后保存

    4. postgresql.conf配置

    vi /var/lib/pgsql/9.3/data/postgresql.conf

    listen_addresses = '*'

    此处主要修改监听本地为监听所有ip,方便远程登入用。

    5. phpPgAdmin.conf配置

    vi \etc\httpd\conf.d\phpPgAdmin.conf

    Alias /phpPgAdmin /usr/share/phpPgAdmin
    
    Order allow,deny
    # Deny from all
    Allow from all
    # Allow from 127.0.0.1
    Allow from ::1
    # Allow from .example.com

    这里一定要配置好allow from all,不要让deny在前面,否则无法登入。

    6. phpPgAdmin的config.inc.php配置

    \usr\share\phpPgAdmin\conf\config.inc.php
    第18行改为

    $conf['servers'][0]['host'] = 'localhost';

    修改未localhost本地还是其它ip就看你要从哪里登入了。

    7. 现在准备登入phpPgAdmin了

    service httpd restart

    重启web apache服务

    service postgresql-9.3 restart

    重启postgresql服务,使刚才做的修改生效。
    访问 http://your ip address/phpPgAdmin/

    注意区分phpPgAdmin的大小写

    在Postgresql的web管理界面,输入登陆名及密码 -安装数据库时创建的用户和密码

     

    8. 相关问题及碰到困难

     

    1. 重置PostgreSQL密码:

     

     

    sudo - postgres
    
    psql
    
    #ALTER USER postgres with password '你的密码';
    \q
    
    exit
    或者有时需要重置postgres用户的linux密码:
    sudo passwd -d postgres 删除linux postgres的密码
    sudo -u postgres passwd 创建linux postgres的密码

     

     

    2. 如果碰到403 forbidden,请检查文件夹权限。

    3. 浏览器提示“您的 PHP 中没有完整的数据库支持”

    这表明没有安装php和php-pgsql软件包

    yum install php-pgsql

    yum会同时安装2个依赖包php-pdo,php-common,它们的安装顺序为php-common php-pdo php-pgsql,也可以手动依次安装。

    4. 网站打开后直接显示源码

    这表明没有安装php

    yum install php

    5. 如果碰到版本冲突

    Error: Package: php-pgsql-5.3.3-40.el6_6.x86_64 (updates)
               Requires: php-common(x86-64) = 5.3.3-40.el6_6
               Installed: php-common-5.4.33-2.el6.remi.x86_64 (@remi)
                   php-common(x86-64) = 5.4.33-2.el6.remi
               Available: php-common-5.3.3-38.el6.x86_64 (base)
                   php-common(x86-64) = 5.3.3-38.el6
               Available: php-common-5.3.3-40.el6_6.x86_64 (updates)
                   php-common(x86-64) = 5.3.3-40.el6_6
     You could try using --skip-broken to work around the problem
     You could try running: rpm -Va --nofiles --nodigest

    解决方案

    rpm -qa | grep php-common 
    rpm -e --nodeps php-common-5.4.33-2.el6.remi.x86_64

    使用强制移出冲突版本需注意其它软件和它依赖的关系,否则会引起其它软件无法运行等问题。

     

奇客罗方公众号 奇客罗方小程序 奇客罗方客服 ITGeeker Telegram

网站由ITGeeker技术奇客开发并管理;隶属于GeekerCloud奇客罗方智能科技
Site designed and developed by ITGeekerwhich is a sub-website of GeekerCloud
网站地图 | 沪ICP备2021031434号-4