環境:
Centos 7 、已經安裝的postgresql11,具體安裝可以查看https://www.cnblogs.com/whitebai/p/12122240.html
1.下載阿里的 repo 資源配置
切換至阿里雲鏡像
[root@pgadmin ~]# cd /etc/yum.repos.d/ [root@pgadmin yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo
2、查詢pgadmin 版本 (可忽略)
[root@localhost ~]# yum search pgadmin
3、選擇安裝pgadmin的版本
[root@pgadmin ~]# yum install -y pgadmin4
此安裝內容有點多,可能會失敗,多安裝幾次,如果下載不來的包可以參考鏈接 https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.0-x86_64/ 去下載相應的包
其它的版本可以通過https://download.postgresql.org/pub/repos/yum/common/redhat/ 這個一層層去找
4、初始化pgadmin
/usr/pgadmin4/bin/pgadmin4-web-setup.sh
輸入登陸郵箱abc@qq.com及密碼123456
5、配置pgadmin4.conf文件 (此步驟盡量用80 ,不操作)
[root@pgadmin ~]# vi /etc/httpd/conf.d/pgadmin4.conf
頭部加入內容:
<VirtualHost *:80>
我在嘗試的時候,反而添加了<VirtualHost *:80> 反而httped 啟動失敗,盡量不要去更改它的端口
6、查看 並啟動httped
啟動:systemctl start httpd.service 查看 :systemctl status httpd.service
7、開放端口
因為我安裝的是默認80 端口,所以需要開放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload
8、外部機器訪問pgadmin4
訪問地址:http://【ip】/pgadmin4
列如:http://182.168.3.1/pgadmin4
輸入初始化的用戶名密碼
9、登錄並操作
如果進行某些操作報錯:Please configure the PostgreSQL Binary Path in the Preferences dialog
打開centos 終端
輸入:which psql
打開pgadmin 中的Preferences
修改完成,即可正常工作!