GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare phpPgAdmin su Ubuntu 18.04/16.04 e LinuxMint 19/18

phpPgAdmin è uno strumento di amministrazione basato sul Web per la gestione del database PostgreSQL ed è molto simile a phpMyAdmin, uno strumento basato sul Web per la gestione di MySQL (MariaDB).

Se hai esperienza di lavoro su phpMyAdmin, è molto facile per te comprendere le funzionalità di phpPgAdmin.

Questa guida ti aiuterà a installare phpPgAdmin su Ubuntu 18.04 / Ubuntu 16.04 e LinuxMint 19 / Linux Mint 18.

Prerequisiti

Prima di configurare phpPgAdmin, dai un'occhiata a come installare PostgreSQL su Ubuntu 18.04 / Ubuntu 16.04 e LinuxMint 19 / Linux Mint 18.

Verifica che il servizio PostgreSQL sia in esecuzione sul server.

sudo systemctl status postgresql

Risultato:

 postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sat 2019-02-23 11:43:07 IST; 23h ago
 Main PID: 6536 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 2323)
   CGroup: /system.slice/postgresql.service

Feb 23 11:43:07 server systemd[1]: Starting PostgreSQL RDBMS...
Feb 23 11:43:07 server systemd[1]: Started PostgreSQL RDBMS.

Installa phpPgAdmin

phpPgAdmin è disponibile nel repository di base, quindi puoi installarlo usando il comando apt-get install.

sudo apt-get install -y  phppgadmin apache2

Configura PostgreSQL

Per impostazione predefinita, PostgreSQL accetta l'autenticazione solo da localhost . Se vuoi connettere PostgreSQL da macchine esterne, dovresti modificare il pg_hba.conf file.

### PostgreSQL 11 ###

sudo nano /etc/postgresql/11/main/pg_hba.conf

### PostgreSQL 10 ###

sudo nano /etc/postgresql/10/main/pg_hba.conf

Inserisci il valore secondo i tuoi requisiti in IPv4 e assicurati che accetti la password md5.

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

host    all             all             192.168.1.0/24          md5 

Configura phpPgAdmin

Modifica /etc/phppgadmin/config.inc.php file.

sudo nano /etc/phppgadmin/config.inc.php

Aggiungi qui le tue istanze PostgreSQL.

        // Display name for the server on the login screen
        $conf['servers'][0]['desc'] = 'PostgreSQL 11';
       

        // Hostname or IP address for server.  Use '' for UNIX domain socket.
        // use 'localhost' for TCP/IP connection on this computer
        $conf['servers'][0]['host'] = 'localhost';
        

        // Database port on server (5432 is the PostgreSQL default)
        $conf['servers'][0]['port'] = 5432;

phpPgAdmin non consentirà agli utenti senza password o con determinati nomi utente (pgsql, postgres, root, amministratore) di accedere.

Per ignorare questa sicurezza aggiuntiva, cambiala in false.

$conf['extra_login_security'] = false;

Impostando questo valore, nascondi semplicemente i database degli altri utenti dall'elenco dei database. Tuttavia, possono ottenere i dati (da altri database) utilizzando query SQL.

$conf['owned_only'] = false;

Configura Apache

A causa delle restrizioni, phpPgAdmin è accessibile solo su localhost. Se vuoi accedere all'interfaccia web di phpPgAdmin da macchine esterne, devi modificare il file di configurazione di Apache (phppgadmin.conf).

sudo nano /etc/apache2/conf-enabled/phppgadmin.conf

La configurazione predefinita apparirà come di seguito.

Alias /phppgadmin /usr/share/phppgadmin

<Directory /usr/share/phppgadmin>

<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
AllowOverride None

# Only allow connections from localhost:
Require local

<IfModule mod_php.c>
  php_flag magic_quotes_gpc Off
  php_flag track_vars On
  #php_value include_path .
</IfModule>
<IfModule !mod_php.c>
  <IfModule mod_actions.c>
    <IfModule mod_cgi.c>
      AddType application/x-httpd-php .php
      Action application/x-httpd-php /cgi-bin/php
    </IfModule>
    <IfModule mod_cgid.c>
     AddType application/x-httpd-php .php
     Action application/x-httpd-php /cgi-bin/php
    </IfModule>
  </IfModule>
</IfModule>

</Directory>

Si prega di commentare il Richiedi locale riga e aggiungi Richiedi tutto concesso appena sotto alla riga commentata.

Sembrerà di seguito.

Alias /phppgadmin /usr/share/phppgadmin

<Directory /usr/share/phppgadmin>

<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
AllowOverride None

# Only allow connections from localhost:
# Require local
Require all granted
<IfModule mod_php.c>
  php_flag magic_quotes_gpc Off
  php_flag track_vars On
  #php_value include_path .
</IfModule>
<IfModule !mod_php.c>
  <IfModule mod_actions.c>
    <IfModule mod_cgi.c>
       AddType application/x-httpd-php .php
       Action application/x-httpd-php /cgi-bin/php
    </IfModule>
    <IfModule mod_cgid.c>
       AddType application/x-httpd-php .php
       Action application/x-httpd-php /cgi-bin/php
    </IfModule>
   </IfModule>
</IfModule>

</Directory

Riavvia i servizi.

sudo systemctl restart postgresql
sudo systemctl restart apache2

Accedi a phpPgAdmin

Ora accedi a phpPgAdmin dal tuo browser web, l'URL sarà

http://il-tuo-indirizzo-ip/phppgadmin

OPPURE:

http://localhost/phppgamin

Pagina iniziale di phpPgAdmin:

Lavora con phpPgAdmin

Fare clic sul server elencato nel riquadro di sinistra per accedere all'istanza PostgreSQL. Accedi utilizzando l'utente del database.

Ora otterrai l'elenco dei database.

Questo è tutto.


Ubuntu
  1. Come installare PostgreSQL su Ubuntu 18.04

  2. Come installare Postgresql e phpPgAdmin su Ubuntu 15.04

  3. Come installare Python 2.7.18 su Ubuntu e LinuxMint

  4. Come installare Python 3.6 su Ubuntu e LinuxMint

  5. Come installare phpPgAdmin su Ubuntu 20.04

Come installare TimescaleDB su Ubuntu 20.04

Come installare PostgreSQL 14 in Ubuntu 20.04

Come installare TimescaleDB su Ubuntu 20.04

Come installare PostgreSQL su Ubuntu 14.04

Come installare PostgreSQL su Ubuntu 15.04

Come installare PostgreSQL su Ubuntu 16.04