apt install libgmp3-dev libpq-dev libapache2-mod-wsgi-py3
mkdir -p /var/lib/pgadmin4/{sessions,storage}
mkdir /var/log/pgadmin4
mkdir ~/environments
apt install python3-venv
python3 -m venv ~/environments/pgadmin4
source ~/environments/pgadmin4/bin/activate
cd /var/lib/pgadmin4/
python -m pip install wheel
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.23/pip/pgadmin4-4.23-py3-none-any.whl
python -m pip install pgadmin4-4.23-py3-none-any.whl
rm -rf pgadmin4-4.23-py3-none-any.whl
chown -R pi:pi /var/lib/pgadmin4
chown -R pi:pi /var/log/pgadmin4
cat <<EOF >> ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
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
EOF
python ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/setup.py
: <<'END_COMMENT'
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: [email protected]
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================
END_COMMENT
deactivate
chown -R www-data:www-data /var/lib/pgadmin4
chown -R www-data:www-data /var/log/pgadmin4
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName pi4.dev.shahed.biz
ServerAdmin [email protected]
DocumentRoot /var/www/html
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/pi/environments/pgadmin4
WSGIScriptAlias /pgadmin4 "/home/pi/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/pgAdmin4.wsgi"
<Directory "/home/pi/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>