如何在 Ubuntu 16.04 LTS 上以服务器模式安装 PgAdmin 4

PgAdmin 4 是对流行的 PostgreSQL 数据库 pgAdmin3 管理工具的重写。

PgAdmin 是 PostgreSQL 领先的图形开源管理、开发和管理工具。

在本教程中,我们将介绍如何在 Ubuntu 16.04 LTS 上以服务器模式安装 PgAdmin 4.

步骤 5. 将 PGAdmin 4 作为服务运行

在开始之前,让我们使用以下命令退出虚拟环境:

# deactivate

要制作 PgAdmin 4,我们需要做一些另外的修改,打开 pgAdmin4.py 文件并在文件的开头插入以下行:

# vi lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
#!/usr/bin/env python
[...]

通过执行以下操作使其可执行:

# chmod +x  lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

现在创建一个 /etc/systemd/system/pgadmin4.service 服务文件,其中包含:

# vi /etc/systemd/system/pgadmin4.service

[Unit]
Description=Pgadmin4 Service
After=network.target

[Service]
User= root
Group= root
# Point to the virtual environment directory
WorkingDirectory=/root/.pgadmin4
# Point to the bin folder of your virtual environment
Environment="PATH=/root/.pgadmin4/bin"
ExecStart="/root/.pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py"
PrivateTmp=true

[Install]
WantedBy=multi-user.target

在系统启动时启用并启动 PgAdmin 服务:

# sudo systemctl daemon-reload
# sudo systemctl enable pgadmin4
# sudo systemctl start pgadmin4
# sudo systemctl status pgadmin4

步骤 6. 访问 PGAdmin 4

打开 http://Server_ip:5050 并使用凭据登录到 PgAdmin。

步骤 1. 安装依赖包

# sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev

步骤 3. 下载并安装 PGAdmin 4

安装 PgAdmin 4 的唯一方法是下载 PgAdmin Python wheel,使用以下命令下载 PgAdmin Python wheel:

# wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl

使用以下命令安装 PgAdmin 4:

# pip install pgadmin4-1.6-py2.py3-none-any.whl

步骤 4. 配置和运行 PGAdmin 4

安装完成后,打开 Config.py 文件并将 DEFAULT_SERVER 参数从环回地址更改为 0.0.0.0,以使 PgAdmin 4 可以从网络中的任何地方访问。

# vi lib/python2.7/site-packages/pgadmin4/config.py
[...]
DEFAULT_SERVER = '0.0.0.0'
[...]

完成配置后,使用以下命令设置 PgAdmin 4:

# python lib/python2.7/site-packages/pgadmin4/setup.py

.
 Enter the email address and password to use for the initial pgAdmin user account:
        Email address: jack@onitroad

我们将提示它添加电子邮件地址和密码以访问 PGAdmin 4

步骤 2. 创建虚拟环境

创建虚拟环境:

# virtualenv .pgadmin4

激活虚拟环境:

# cd .pgadmin4
# source bin/activate
日期:2020-06-02 22:18:17 来源:oir作者:oir