如何在 Ubuntu 20.04 上安装 PgAdmin 4

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

在本教程中,我们将介绍如何在 Ubuntu 20.04 LTS 上使用 apache2 和 Wsgi 模块在服务器模式下将 pgAdmin4 安装为 Web 应用程序。

在 Ubuntu 20.04 上安装 pgAdmin4

01 首先,让我们通过运行以下命令导入 pgAdmin4 密钥:

$curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add

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

$sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

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

$sudo apt install pgadmin4-web

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

$sudo /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Debian 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...
We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y
The Apache web server is running. A restart is required for the pgAdmin 4 installation to complete. Would you like to continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode

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

如果我们配置了 UFW 防火墙,请通过运行以下命令来允许 http 流量:sudo ufw allow http

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

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