如何在 CentOS 8 上安装 PgAdmin 4

pgAdmin 是 PostgreSQL 领先的图形开源管理、开发和管理工具。
pgAdmin4 是对 PostgreSQL 数据库流行的 pgAdmin3 管理工具的重写。

在本教程中,我们将展示如何在 CentOS 8 上使用 httpd 和 Wsgi 模块在服务器模式下将 pgAdmin4 安装为 Web 应用程序。

在 CentOS 8 上安装 pgAdmin4

01要在 CentOS 8 上安装 pgAdmin4,我们需要添加一个外部存储库,因此执行以下命令:

$sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-1-1.noarch.rpm

02 添加 pgAdmin4 存储库后,让我们使用以下命令将 pgAdmin4 安装为服务器模式:

$sudo dnf install pgadmin4-web

03 在继续配置 pgAdmin4 之前,我们需要安装 policycoreutils工具:

$dnf install policycoreutils-python-utils

04 安装完 pgAdmin4 后,我们需要通过设置初始 pgAdmin 用户帐户和 Apache Web 服务器来配置 pgAdmin4,如下所示:

$sudo /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Redhat platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: jack@onitroad
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================
Creating storage and log directories...
Configuring SELinux...
The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Would you like to continue (y/n)? y
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Apache successfully enabled.
Apache successfully started.
You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

05 如果我们配置了 firewalld,请通过运行以下命令来允许 http 流量:

$sudo firewall-cmd --permanent --add-service=http
$sudo firewall-cmd --reload

06 为了让HTTPD Wsgi模块连接到网络,我们需要如下配置Selinux:

$setsebool -P httpd_can_network_connect 1

07 要验证 pgAdmin4 是否已成功安装,请打开 Web 浏览器并转到以下地址:http://your-server_ip/pgadmin4/或者 http://localhost/pgadmin4/

现在,输入我们在安装过程中创建的电子邮件地址和密码,我们将看到控制面板页面。

日期:2020-06-02 22:18:17 来源:oir作者:oir