Linux下安装pgadmin,并外部访问

环境:

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

修改完成,即可正常工作!

原文地址:https://www.cnblogs.com/whitebai/p/13094540.html