Installing pgAdmin4 (4.2) on FreeBSD-12 - SOLVED
Mark Moellering
markmoellering at psyberation.com
Sat Feb 9 19:03:10 UTC 2019
Having just done this, I wanted to post this here, in case this will help
others.
This is based off of a Computing For Geeks article by Josphat Mutai, but I
felt there were a couple of pieces missing.
I installed this on my local development machine, "hal" in the examples,
not the postgresql server but I don't think that should change much beyond
the connection definitions once pgadmin4 is up and running.
(original article)
https://computingforgeeks.com/how-to-install-pgadmin4-on-freebsd-12/
pgadmin4 can use python 2.7 or 3.6 As python 2.7 has an end of life of
Jan, 1 2020, I opted for python 3.6
Pre-Installation Setup
install python36 -- pkg install python36
install python pip package manager -- pkg install py36-pip
install python virtualenvironment -- pkg install py36-virtualenv
Installing pgAdmin4
As Root, go to /usr/local
start a python virtual environment for pgadmin4:
root at hal:/usr/local # virtualenv-3.6 pgadmin4
Then run:
source pgadmin4/bin/activate
This did not work for me, so I had to use:
root at hal:/usr/local # source pgadmin4/bin/activate.csh
Next, load the python dependancies through pip:
[pgadmin4] root at hal:/usr/local #pip install pyopenssl cryptography pyasn1
ndg-httpsclient
Then, load sqlite3:
[pgadmin4] root at hal:/usr/local #pkg install py36-sqlite3
Finally, install pgAdmin4 using pip. Make sure to check for the latest
version and directory:
[pgadmin4] root at hal:/usr/local #pip install
https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.2/pip/pgadmin4-4.2-py2.py3-none-any.whl
(On my 8-core Ryzen, this took less than a minute.)
Configuration and running
To exit the python virtual environment, run:
#deactivate.
I exited the virtual environment at this point, but I don't think it is
necessary.
next, in the directory:
root at hal:/usr/local/pgadmin4/lib/python3.6/site-packages/pgadmin4
run:
cp config.py to config_local.py
- and edit the config_local.py file
around line 140, it will have;
DEFAULT_SERVER = '127.0.0.1'
THIS WILL NOT WORK. You must change it to;
DEFAULT_SERVER = '0.0.0.0' (or a static IP, if you have one)
To run pgAdmin4, you must be in the python virtual environment, and then
run the pgAdmin4.py script;
root at hal:/usr/local # virtualenv-3.6 pgadmin4
root at hal:/usr/local # source pgadmin4/bin/activate.csh
[pgadmin4] root at hal:/usr/local # python
./pgadmin4/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
It will ask for an email address and password the first time you run it, as
displayed below;
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user
account:
Email address: markmoellering at psyberation.com
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================
Starting pgAdmin 4. Please navigate to http://0.0.0.0:5050 in your browser.
And it should work (it did for me at any rate).
I went http://127.0.0.1:5050 and was able to log in and attach to my remote
server. When I initially left the DEFAULT_SERVER = '127.0.0.1', I could
login but then the web-stie would crash. I changed the setting to 0.0.0.0
and then http://127.0.0.1:5050 worked as expected. I haven't written an rc
script for it yet but I may in the future.
I hope this helps someone. While the original instructions by Josphat
Mutai were quite good, there were just a couple of gotchas that I thought
should be explained in more detail
-- Mark
More information about the freebsd-questions
mailing list