Install pgAdmin 4 as a service under linux

Learn how to install pgAdmin 4 as a service under linux.

Install pgAdmin 4 as a service under linux

Now that pgAdmin 4 is out you may want to install it on your linux machine.

As for debian/ubuntu at least there aren't any packages build yet here's a way to do it.

Create a Python 3 virtual environment

You can do without a virtual environment but that's how I like to do things.

Install the needed packages (you can also build Python from source if you fancy another Python version that what you already have in your OS) with sudo apt-get install python3-dev python3-venv wget

Create a virtual environment and activate it with:
python3 -m venv pgadmin4 && source pgadmin4/bin/activate

Download, configure and run

pip install wheel
pip install pgadmin4-6.11-py3-none-any.whl

As I want to use the Desktop mode I created the pgadmin4/lib/python3.9/site-packages/pgadmin4/ file and I added according to my usual login user, qgis:

LOG_FILE = '/home/qgis/.pgadmin/pgadmin4.log'
SQLITE_PATH = '/home/qgis/.pgadmin/pgadmin4.db'
SESSION_DB_PATH = '/home/qgis/.pgadmin/sessions'
STORAGE_DIR = '/home/qgis/.pgadmin/storage'

Run python pgadmin4/lib/python3.9/site-packages/pgadmin4/ and the setup should be completed.
Depending on your setup, if you encounter permissions errors you should re-run the above command after you fix them.

You can test that everything works as it should by doing python pgadmin4/lib/python3.9/site-packages/pgadmin4/ and by opening your web browser to http://localhost:5050

Create a service

Create a /etc/systemd/system/pgadmin4.service service file containing:

Description=Pgadmin4 Service

ExecStart=/home/qgis/Downloads/pgadmin4/bin/python /home/web/Downloads/pgadmin4/lib/python3.9/site-packages/pgadmin4/


Run the service with sudo systemctl start pgadmin4.

Test if everything is fine by doing sudo systemctl status pgadmin4.

Set it up to autostart when linux boots by doing a sudo systemctl enable pgadmin4.

That's it!

Share Tweet Send
You've successfully subscribed to
Great! Next, complete checkout for full access to
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.