Denne vejledning viser dig, hvordan du installerer pgAdmin 4 på Ubuntu 20.04/18.04/16.04. pgAdmin er et open source PostgreSQL administrations- og udviklingsværktøj, pgAdmin bruges grundlæggende til at administrere PostgreSQL-databaseserveren.
Du skal have en PostgreSQL-server på et lokalt eller eksternt system/VM. Hvis du ikke har, så se nedenstående dokument og installer PostgreSQL. Til denne øvelse har jeg installeret PostgreSQL-serveren og pgAdmin-værktøjet på det samme Ubuntu-system.
Sådan installeres PostgreSQL 12 på Ubuntu 20.04/18.04/16.04
Trin for at installere pgAdmin4 på Ubuntu
Trin 1:Tilføj PostgreSQL APT-lager
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - 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'
Eksempeloutput:
root@PostgreSQL:~# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). OK root@PostgreSQL:~# 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' Hit:1 http://us.archive.ubuntu.com/ubuntu groovy InRelease Hit:2 http://security.ubuntu.com/ubuntu groovy-security InRelease Hit:3 http://us.archive.ubuntu.com/ubuntu groovy-updates InRelease Hit:4 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4 InRelease Hit:5 http://us.archive.ubuntu.com/ubuntu groovy-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 206 packages can be upgraded. Run 'apt list --upgradable' to see them. root@PostgreSQL:~#
Trin 2:Installer pgAdmin4 på Ubuntu
sudo apt install pgadmin4
Eksempeloutput:
root@PostgreSQL:~# sudo apt install pgadmin4 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: virtualbox-guest-utils Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libapache2-mod-wsgi-py3 pgadmin4-desktop pgadmin4-server pgadmin4-web The following NEW packages will be installed: libapache2-mod-wsgi-py3 pgadmin4 pgadmin4-desktop pgadmin4-server pgadmin4-web 0 upgraded, 5 newly installed, 0 to remove and 206 not upgraded. Need to get 79.7 MB/161 MB of archives. After this operation, 300 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main amd64 pgadmin4-desktop amd64 5.2 [79.7 MB] Get:2 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main all pgadmin4-web all 5.2 [2,640 B] Get:3 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main all pgadmin4 all 5.2 [840 B] Fetched 69.0 MB in 59s (1,178 kB/s) Selecting previously unselected package libapache2-mod-wsgi-py3. (Reading database ... 195104 files and directories currently installed.) Preparing to unpack .../libapache2-mod-wsgi-py3_4.7.1-2_amd64.deb ... Unpacking libapache2-mod-wsgi-py3 (4.7.1-2) ... Selecting previously unselected package pgadmin4-server. Preparing to unpack .../pgadmin4-server_5.2_amd64.deb ... Unpacking pgadmin4-server (5.2) ... Selecting previously unselected package pgadmin4-desktop. Preparing to unpack .../pgadmin4-desktop_5.2_amd64.deb ... Unpacking pgadmin4-desktop (5.2) ... Selecting previously unselected package pgadmin4-web. Preparing to unpack .../pgadmin4-web_5.2_all.deb ... Unpacking pgadmin4-web (5.2) ... Selecting previously unselected package pgadmin4. Preparing to unpack .../archives/pgadmin4_5.2_all.deb ... Unpacking pgadmin4 (5.2) ... Setting up pgadmin4-server (5.2) ... Setting up libapache2-mod-wsgi-py3 (4.7.1-2) ... apache2_invoke: Enable module wsgi Setting up pgadmin4-desktop (5.2) ... Setting up pgadmin4-web (5.2) ... Setting up pgadmin4 (5.2) ... Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... Processing triggers for desktop-file-utils (0.24-1ubuntu4) ... root@PostgreSQL:~#
Trin 3:Konfigurer pgAdmin4-legitimationsoplysninger
sudo /usr/pgadmin4/bin/setup-web.sh
Erstat e-mail-id [email protected] og konfigurer din stærke adgangskode.
Efter installationen vil Apache-tjenesten blive startet
$ systemctl status apache2
Eksempeloutput:
root@PostgreSQL:~# systemctl status apache2 ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor pres> Active: active (running) since Sun 2021-05-16 12:28:13 EDT; 4min 37s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 25828 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/> Main PID: 25832 (apache2) Tasks: 34 (limit: 4648) Memory: 33.9M CGroup: /system.slice/apache2.service ├─25832 /usr/sbin/apache2 -k start ├─25833 /usr/sbin/apache2 -k start ├─25834 /usr/sbin/apache2 -k start ├─25835 /usr/sbin/apache2 -k start ├─25836 /usr/sbin/apache2 -k start ├─25837 /usr/sbin/apache2 -k start └─25838 /usr/sbin/apache2 -k start May 16 12:28:12 PostgreSQL systemd[1]: Starting The Apache HTTP Server... May 16 12:28:13 PostgreSQL apachectl[25831]: AH00558: apache2: Could not relia> May 16 12:28:13 PostgreSQL systemd[1]: Started The Apache HTTP Server. root@PostgreSQL:~#
Trin 4:Konfigurer firewall på Ubuntu (valgfrit)
sudo ufw allow http sudo ufw allow https
Eksempeloutput:
root@PostgreSQL:~# sudo ufw allow http Rules updated Rules updated (v6) root@PostgreSQL:~# sudo ufw allow https Rules updated Rules updated (v6) root@PostgreSQL:~#
Trin 5:Få adgang til pgadmin4 på webbrowser
http://[ServerIP_eller_domæne]/pgadmin4
Log på med legitimationsoplysninger, som vi har oprettet i trin 3
Når du logger ind, får du nedenstående skærmbillede.
Trin 6:Tilføj en PostgreSQL-server til at administrere med pgAdmin
Klik på "Tilføj ny server" (du kan tilføje lokal eller ekstern PostgreSQL-server)
Under "Generelt ” sektion, Giv PostgreSQL-servernavn med beskrivelse
Klik nu på "Forbindelse fanen”, giver serverdetaljer som PostgreSQL IP/vært, databasebruger og adgangskode
Gem det nu. Hvis al konfiguration er korrekt, vil du kunne se PostgreSQL-serveren på venstre side.
I slutningen af artiklen har vi set, hvordan man installerer pgAdmin 4 på Ubuntu 20.04/18.04/16.0 og udforsker mere på pgAdmins web-UI.