温馨提示×

PgAdmin在Linux上如何配置

小樊
43
2025-02-23 04:27:16
栏目: 智能运维
Linux服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Linux上配置PgAdmin涉及多个步骤,具体步骤可能会因Linux发行版而异,但以下是在RHEL 9、Ubuntu 16.04和CentOS 8上配置PgAdmin的一般指南:

在RHEL 9上配置PgAdmin

  1. 添加PgAdmin4仓库

    • 安装EPEL仓库:
      sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
      
    • 安装PgAdmin4仓库:
      sudo dnf install-y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
      
    • 建立缓存:
      sudo dnf makecache
      
  2. 安装PgAdmin4

    sudo dnf install pgadmin4-y
    
  3. 启动/启用PgAdmin4服务

    sudo systemctl start httpd
    sudo systemctl enable httpd
    
  4. 初始化PgAdmin4

    sudo /usr/pgadmin4/bin/setup-web.sh
    

    提供电子邮件和密码进行配置。

  5. 访问PgAdmin4的Web界面: 在浏览器中输入:http://server-ip/pgadmin4,使用提供的凭据登录。

在Ubuntu 16.04上配置PgAdmin

  1. 安装依赖包

    sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
    
  2. 创建虚拟环境

    cd /opt
    mkdir environmentpy
    cd environmentpy
    virtualenv pgadmin4
    cd pgadmin4
    source bin/activate
    
  3. 下载并安装PgAdmin 4

    wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.3/pip/pgadmin4-1.3-py2.py3-none-any.whl
    pip install pgadmin4-1.3-py2.py3-none-any.whl
    
  4. 创建本地配置文件

    cd /lib/python2.7/site-packages/pgadmin4
    touch config_local.py
    

    编辑config_local.py文件,设置服务器模式为False

  5. 运行PgAdmin 4

    python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
    

    按照提示设置电子邮件和密码。

  6. 访问PgAdmin 4: 在浏览器中输入:http://localhost:5050,使用设置的凭据登录。

在CentOS 8上配置PgAdmin

  1. 安装PgAdmin 4

    sudo dnf install pgadmin4
    
  2. 启动/启用PgAdmin4服务

    sudo systemctl start httpd
    sudo systemctl enable httpd
    
  3. 访问PgAdmin4的Web界面: 在浏览器中输入:http://server-ip/pgadmin4,使用设置的凭据登录。

请注意,以上步骤可能会因PgAdmin版本和Linux发行版的不同而有所变化。建议参考PgAdmin的官方文档以获取最准确的安装和配置指南。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:pgAdmin在Linux上的配置步骤

0