install pgadmin
===============
apt update
sudo apt install libgmp3-dev libpq-dev libapache2-mod-wsgi-py3
sudo mkdir -p /var/lib/pgadmin4/sessions
sudo mkdir /var/lib/pgadmin4/storage
sudo mkdir /var/log/pgadmin4
adduser andre
sudo chown -R sammy:sammy /var/lib/pgadmin4
sudo chown -R sammy:sammy /var/log/pgadmin4
cd environments/
source my_env/bin/activate
wget http://apt.postgresql.org/pub/pgadmin/pgadmin4/v4.9/pip/pgadmin4-4.9-py2.py3-none-any.whl
python -m pip install wheel
python -m pip install pgadmin4-4.9-py2.py3-none-any.whl
edit
environments/my_env/lib/python3.7/site-packages/pgadmin4/config_local.py
add this line:
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
SERVER_MODE = True
python my_env/lib/python3.7/site-packages/pgadmin4/setup.py
deactivate
sudo chown -R www-data:www-data /var/lib/pgadmin4/
sudo chown -R www-data:www-data /var/log/pgadmin4/
add port 8000
nano /etc/apache2/ports.conf
Listen 8000
sudo nano /etc/apache2/sites-available/pgadmin4.conf
add this line:
<VirtualHost *:8000>
#ServerName your_server_ip
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/sammy/environments/my_env
WSGIScriptAlias / /home/sammy/environments/my_env/lib/python3.7/site-packages/pgadmin4/pgAdmin4.wsgi
<Directory "/home/sammy/environments/my_env/lib/python3.7/site-packages/pgadmin4/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
sudo a2dissite 000-default.conf
sudo a2ensite pgadmin4.conf
sudo a2ensite 000-default.conf
apachectl configtest
sudo systemctl restart apache2
---
tambahan
=========
Aktifkan Server PostgreSQL
# systemctl start postgresql.service
# systemctl enable postgresql.service
# systemctl status postgresql.service
Membuat Password PostgreSQL
# su - postgres
> psql
> \password postgres
>\q
# logout;
Mengaktifkan Remote Akses ke database postgresql
# nano /etc/postgresql/9.6/main/postgresql.conf
cari di bagian listen_address dan password_encryption ubah seperti berikut
listen_addresses = '*'
password_encryption = on
# nano /etc/postgresql/9.6/main/pg_hba.conf
Tambahkan Host seperti contoh berikut
host all all 0.0.0.0/0 md5
host all all ::/0 md5
# /etc/init.d/postgresql restart
By Niammuddin Mz
January 11, 2020