PgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL database.
PgAdmin is the leading graphical Open Source management, development and administration tool for PostgreSQL.
In this tutorial, we are going to show you How to install PgAdmin 4 in Server Mode on Ubuntu 16.04 LTS.
If you didn’t yet install PostgreSQL take a look the below links :
- How to Install PostgreSQL on Ubuntu 16.04 LTS
- How To Install PostgreSQL 9.6 on CentOS 7 / RHEL 7
- How To Change PostgreSQL Data Directory Location on Ubuntu 16.04
- How To Enable Network Remote Access To PostgreSQL Database Server
- How to install pgAdmin 4 in desktop mode on Ubuntu 16.04 LTS
- How to install pgAdmin 4 in Server mode as web application on CentOS 7 / RHEL 7
- How to install PgAdmin 4 in Server Mode as a Web Application using WSGI on Ubuntu 18.04 LTS / Ubuntu 16.04 LTS
Step 1. Install Dependencies Packages
# sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
Step 2. Create the virtual environment
– Create the virtual enviroment:
# virtualenv .pgadmin4
– Activate the virtual enviroment:
# cd .pgadmin4 # source bin/activate
Step 3. Download and install PGAdmin 4
– The only way to install PgAdmin 4 is to download the PgAdmin Python wheel, use the following command to download PgAdmin Python wheel:
# wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl
– Install PgAdmin 4 using the following command:
# pip install pgadmin4-1.6-py2.py3-none-any.whl
Step 4. Configure and Run PGAdmin 4
– Once you finished with the installation, open the Config.py file and change DEFAULT_SERVER parameter from loopback address to 0.0.0.0 to make PgAdmin 4 accessed from everywhere in the network.
# vi lib/python2.7/site-packages/pgadmin4/config.py [...] DEFAULT_SERVER = '0.0.0.0' [...]
– Once you finished the configuration, use the following command to setup PgAdmin 4:
# python lib/python2.7/site-packages/pgadmin4/setup.py . Enter the email address and password to use for the initial pgAdmin user account: Email address: firstname.lastname@example.org
you will prompt it to add an email address and a password to access PGAdmin 4
Step 5. Run PGAdmin 4 as a Service
– Before we start let’s exit the virtual enviroment using the follwoing command:
– To make PgAdmin 4 we need to make some extra modification, Open the pgAdmin4.py file and insert the following line in the begin of the file:
# vi lib/python2.7/site-packages/pgadmin4/pgAdmin4.py #!/usr/bin/env python [...]
– Make it executable by doing:
# chmod +x lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
– Now create a /etc/systemd/system/pgadmin4.service service file containing:
# vi /etc/systemd/system/pgadmin4.service [Unit] Description=Pgadmin4 Service After=network.target [Service] User= root Group= root # Point to the virtual environment directory WorkingDirectory=/root/.pgadmin4 # Point to the bin folder of your virtual environment Environment="PATH=/root/.pgadmin4/bin" ExecStart="/root/.pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py" PrivateTmp=true [Install] WantedBy=multi-user.target
– Enable and start PgAdmin Service at system boot:
# sudo systemctl daemon-reload # sudo systemctl enable pgadmin4 # sudo systemctl start pgadmin4 # sudo systemctl status pgadmin4
Step 6. Access PGAdmin 4
– Open http://Server_ip:5050 and logon to the PgAdmin using your credentials.
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.