在 CentOS 上配置 pgAdmin(以 pgAdmin 4 为例,目前主流版本)通常有两种方式:
下面以 CentOS 7 / CentOS 8 / Rocky / Alma 类似系统 为例说明。
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
CentOS 7 用:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf install -y pgadmin4-web
或 CentOS 7:
sudo yum install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
过程中会提示:
sudo systemctl enable httpd
sudo systemctl start httpd
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --reload
浏览器访问:
http://服务器IP/pgadmin4
使用初始化时设置的邮箱和密码登录。
若连接 localhost 失败,检查 PostgreSQL 是否允许本地连接:
/var/lib/pgsql/<版本>/data/pg_hba.conf
sudo setsebool -P httpd_can_network_connect on
sudo chown -R apache:apache /var/lib/pgadmin
sudo systemctl start postgresql-15
sudo dnf install -y pgadmin4-desktop
如果你说的是 CentOS 具体版本 或 Docker 方式 / 离线安装,可以告诉我,我可以给你更精确的配置步骤。