在 CentOS 上配置 pgAdmin(以 pgAdmin 4 为例,目前最常用),常见有两种方式:
下面以 CentOS 7 / 8 / Stream + pgAdmin 4 (Web) 为例说明。
sudo yum install -y epel-release
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
过程中会提示:
示例:
Email address: admin@local.com
Password: ********
sudo yum install -y nginx
server {
listen 80;
server_name pgadmin.example.com;
location / {
proxy_pass http://127.0.0.1:5050;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
sudo systemctl restart nginx
sudo systemctl start httpd # 如果使用 Apache
# 或
sudo systemctl start nginx
pgAdmin 默认监听:
http://服务器IP:5050
sudo firewall-cmd --add-port=5050/tcp --permanent
sudo firewall-cmd --reload
浏览器访问:
http://服务器IP:5050
使用初始化时设置的:
127.0.0.1 或远程 IP5432/var/log/pgadmin/pgadmin4.log
修改:
# postgresql.conf
listen_addresses = '*'
# pg_hba.conf
host all all 0.0.0.0/0 md5
如果你用的是 CentOS 哪个版本、pgAdmin 3 还是 4、Web 还是桌面,可以告诉我,我可以给你更精确的步骤。