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:
pyvenv-3.5 pgadmin4 && source pgadmin4/bin/activate

Download, configure and run

pip install wheel
pip install pgadmin4-1.5-py2.py3-none-any.whl

Edit the pgadmin4/lib/python3.5/site-packages/pgadmin4/ file and change the SERVER_MODE = True to SERVER_MODE = False.

Run python pgadmin4/lib/python3.5/site-packages/pgadmin4/ and follow the setup wizard.

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

Create a service

Edit the pgadmin4/lib/python3.5/site-packages/pgadmin4/ file and add #!/usr/bin/env python as a first line.
Also make it executable by doing chmod u+x pgadmin4/lib/python3.5/site-packages/pgadmin4/

Now create a /etc/systemd/system/pgadmin4.service service file containing:

Description=Pgadmin4 Service

# Point to the bin folder of your virtual environment


Run the service with sudo systemctl start pgadmin4.

Test if everything is fine by doing sudo systemctl status.

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

That's it!

Related Article