How to Install pgAdmin4 on FreeBSD 12

Posted on 41 views

pgAdmin is the leading Open Source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows. It provides a powerful GUI which ease your Database management and operations.

pgAdmin allows you to manage PostgreSQL 9.2 and above. As of this writing, the latest release of pgAdmin is v4 which had migration from Bootstrap 3 to Bootstrap 4.

Setup Pre-requisites

As a pre-requisite, you need to have:

  • FreeBSD server
  • PostgreSQL server installed
  • User account with sudo privileges

Step 1: Install PostgreSQL database server

For the installation of PostgreSQL database server, refer to our previous guide:

Step 2: Update FreeBSD system

In my setup, I’m installing pgAdmin on the same server running PostgreSQL. But you have an option of setting it up on a different server.

First update the FreeBSD Repository Database.

freebsd-update fetch
freebsd-update install

Step 3: Install Python pip & Virtualenv

Create Python 3.8 symbolic link to /usr/local/bin/python.

sudo ln -s /usr/local/bin/python3.8 /usr/local/bin/python

pip is required for installing Python packages. Install it on your FreeBSD server by following below guide.

Summarized Python setup:

sudo pkg install py38-pip
sudo pip install --upgrade pip
sudo pkg install py38-virtualenv

Step 4: Install pgAdmin packages

Create a virtual environment for pgAdmin4 by running:

$ sudo virtualenv-3.8 pgadmin4
Using base prefix '/usr/local'
New python executable in /root/pgadmin4/bin/python3.8
Also creating executable in /root/pgadmin4/bin/python
Installing setuptools, pip, wheel...
done.

Activate the Virtual environment created:

source pgadmin4/bin/activate

If it fails, use:

source pgadmin4/bin/activate.csh

Install Python dependencies for pgAdmin:

sudo pip install cryptography==3.1.1 pyopenssl ndg-httpsclient pyasn1 simple-websocket

Then install the standard Python binding to the SQLite3 library. For python 3.8, run:

sudo pkg install py38-sqlite3

For Python 2.7, use:

sudo pkg install py27-sqlite3

Check for the latest release of pgAdmin4 before downloading. Once you get the path to latest release, install it with the pip command.

sudo pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v6.9/pip/pgadmin4-6.9-py3-none-any.whl

This installation may take some time as a number of dependencies are installed, so be patient.

When done create data directories for pgAdmin4

sudo mkdir -p /var/lib/pgadmin /var/log/pgadmin
sudo chmod 770 /var/lib/pgadmin /var/log/pgadmin

Step 5: Configure and run pgAdmin 4

After the installation, configuration file should be created for pgAdmin 4.

cp ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config.py ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config_local.py

For Python 2.7, replace python3.6 with python2.7

Change the default server Listen address on to 0.0.0.0

vim ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config_local.py

This is around line 138

DEFAULT_SERVER = '0.0.0.0'

The default listen port is 5050 but you can change it to your desired port.

The default port on which the app server will listen if not set in the environment by the runtime
DEFAULT_SERVER_PORT = 5050

Use following command to run pgAdmin.

$ sudo python ./pgadmin4/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: [email protected]
Password: 
Retype password: 
pgAdmin 4 - Application Initialisation
Starting pgAdmin 4. Please navigate to http://0.0.0.0:5050 in your browser.

The first run will ask you to Enter the email address and the password to use for the pgAdmin user account.

Step 6: Access pgAdmin Web Interface

Now that we have pgAdmin4 installed and running, you can access its web dashboard by visiting the URL “http://your_server_ip:5050“.

install-pgAdmin-freebsd-12-login-1024x442

Login with created user email address and password. After login, you’ll need to connect to your PostgreSQL server.

install-pgAdmin-freebsd-12-01

Enter server connection name and group.

install-pgAdmin-freebsd-12-02-1024x777

Under “Connection” tab, provide access details – DB host, DB user and Password.

install-pgAdmin-freebsd-12-03-1013x1024

Save the settings to activate your connection.

install-pgAdmin-freebsd-12-04-1024x422

You can now enjoy using pgAdmin for your PostgreSQL database management tasks.

If you’re a MariaDB user, check:

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.