Adjust paths according to your preferences
Requirements:
sudo apt install python2.7-dev virtualenv python-pip libpq-dev
Set up a virtual environment for python:
mkdir ~/pgadmin4
cd ~/pgadmin4
virtualenv venv -p /usr/bin/python2.7
source ./venv/bin/activate
Download pip wheel distribution of pgadmin4 (check this for the latest pip link: https://www.postgresql.org/ftp/pgadmin/pgadmin4/)
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl
pip install pgadmin4-1.6-py2.py3-none-any.whl
Test it by running:
python ./venv/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
then go to http://localhost:5050, if everything is working as it should you will be greeted by a login form.
Press CTRL-C to stop the execution.
Type deactivate
in your shell to exit the venv.
Create a config file:
cd ~/pgadmin4/venv/lib/python2.7/site-packages/pgadmin4
cp config.py config_local.py
nano config_local.py
If you intend to run pgAdmin4 just locally on your machine, all you need to do is to edit the server mode to false:
SERVER_MODE = False
Refer to the official documentation for advanced / proper server setups.
Create these two files, remember to adjust the paths for your environment:
cd ~/pgadmin4/
pgadmin4.sh:
#!bin/bash
cd /home/youruser/pgadmin4
source ./venv/bin/activate
python ./venv/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
pgadmin4.service:
[Unit]
Description=pgAdmin4
After=network.target
[Service]
User=youruser
Type=simple
ExecStart=/home/youruser/pgadmin4/pgadmin4.sh
Restart=always
[Install]
WantedBy=multi-user.target
Make pgadmin4.sh executable and symlink the service file pgadmin4.service
into /etc/systemd/system
:
chmod +x ~/pgadmin4/pgadmin4.sh
sudo ln -s ~/pgadmin4/pgadmin4.service /etc/systemd/system/
sudo systemctl daemon-reload
To start the service:
sudo systemctl start pgadmin4
To stop the service:
sudo systemctl stop pgadmin4
Enable the service to be started with your system:
sudo systemctl enable pgadmin4