You are on page 1of 4

Install pgAdmin 4 as a service under linux https://blog.qtibia.ro/2016/11/01/install-pgadmin-4-as-a-service-und...

MENU

Install pgAdmin 4 as a service


under linux
01 NOVEMBER 2016

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, congure and run

wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.3/pip
/pgadmin4-1.3-py2.py3-none-any.whl
pip install wheel
pip install pgadmin4-1.3-py2.py3-none-any.whl

Edit the pgadmin4/lib/python3.5/site-packages/pgadmin4/config.py le and


change the SERVER_MODE = True to SERVER_MODE = False .

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


the setup wizard.

You can test that everything works as it should by doing python pgadmin4/lib
/python3.5/site-packages/pgadmin4/pgAdmin4.py and by opening your web

browser to http://localhost:5050

Create a service

Edit the pgadmin4/lib/python3.5/site-packages/pgadmin4/pgAdmin4.py le and


QTIBIA ENGINEERING blog 2017
add
Proudly published with Ghost

1 de 4 18/04/17 11:42
Install pgAdmin 4 as a service under linux https://blog.qtibia.ro/2016/11/01/install-pgadmin-4-as-a-service-und...

#!/usr/bin/env python as a rst line.

Also make it executable by doing chmod u+x pgadmin4/lib/python3.5/site-


packages/pgadmin4/pgAdmin4.py .

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

[Unit]
Description=Pgadmin4 Service
After=network.target

[Service]
User=qgis
Group=qgis
WorkingDirectory=/home/qgis/Downloads/pgadmin4/
# Point to the bin folder of your virtual environment
Environment="PATH=/home/qgis/Downloads/pgadmin4/bin"
ExecStart=/home/qgis/Downloads/pgadmin4/lib/python3.5/site-packages
/pgadmin4/pgAdmin4.py
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Run the service with sudo systemctl start pgadmin4 .

Test if everything is ne by doing sudo systemctl status .

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


pgadmin4 .

That's it!

2 de 4 18/04/17 11:42
Install pgAdmin 4 as a service under linux https://blog.qtibia.ro/2016/11/01/install-pgadmin-4-as-a-service-und...

18 Comments Qtibia Engineering Blog


1 Login

Sort by Best
Recommend Share

Join the discussion

theo 3 months ago


Hi,

I followed that post and I have a problem. When I execute sudo systemctl status pgadmin4.service
the reponse is:
pgadmin4.service - PgAdmin4 Service
Loaded: loaded (/etc/systemd/system/pgadmin4.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since lun 2017-01-09 12:26:11 CET; 6s ago
Main PID: 3286 (code=exited, status=200/CHDIR)

ene 09 12:26:11 linux-informatica-04 systemd[1]: Started PgAdmin4 Service.


ene 09 12:26:11 linux-informatica-04 systemd[1]: pgadmin4.service: Main process exited,
code=exited, status=200/CHDIR
ene 09 12:26:11 linux-informatica-04 systemd[1]: pgadmin4.service: Unit entered failed state.
ene 09 12:26:11 linux-informatica-04 systemd[1]: pgadmin4.service: Failed with result 'exit-code'.

I don't know solve that problem...

Thanks a lot.
Reply Share

tudorbarascu Mod > theo 3 months ago


Doing a systemctl status -l pgadmin4.service should give more insight on what's happening.
Reply Share

theo > tudorbarascu 3 months ago


Hi,

The instruction that you say returns this information:

pgadmin4.service - PgAdmin4 Service


Loaded: loaded (/etc/systemd/system/pgadmin4.service; disabled; vendor preset:
enabled)
Active: inactive (dead)

Thanks for you reply.


Reply Share

tudorbarascu Mod > theo 3 months ago


Please try sudo journalctl -u pgadmin4 and see if we can see the error.
Reply Share

theo > tudorbarascu 3 months ago


This instruction response:
-- No entries --
Reply Share

tudorbarascu Mod > theo 3 months ago


Without seeing the actual error I cannot tell what's wrong.

But I would check if 1) you have the correct paths in your pgadmin4.service
file and that 2) you can start pgAdmin4.py manually.
Reply Share

theo > tudorbarascu 3 months ago


Hi,
Yes, I can start pgAdmin4 manually and it works fine.
The paths are correct too.
Thx
Reply Share

Marc Hanisch > theo 2 months ago


Hey Theo, I had the same problem when I updated my installation to
pgAdmin4 1.2 and I simply forgot to add '#!/usr/bin/env python' to

3 de 4 18/04/17 11:42
Install pgAdmin 4 as a service under linux https://blog.qtibia.ro/2016/11/01/install-pgadmin-4-as-a-service-und...

Tudor Brscu Share this


post
QGIS platform, PostgreSQL, Linux and other FOSS software passionate with
experience in the water/wastewater sector.
Ramnicu Valcea, Romania https://github.com/tudorbarascu

YOU MIGHT ENJOY

Build python-qt4 from source on Debian


testing
As QtWebKit Python bindings were removed from Debian Testing/Stretch QGIS
is unable to start with Python support and

4 de 4 18/04/17 11:42

You might also like