How To Install and Config Postgresql and pgadmin4 for running node
For Running And install postgresql on ubunto better use 20.04 or 22 . and after update install package’s lib , and Create New User and make administrator .
now install pgadmin4 for management . before installing create data base and make a new user on sql and generated new rule for new user . can running all section section to section and line to line .
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install ubuntu-desktop -y
sudo apt install gnome-software -y
sudo apt-get install xrdp htop -y
sudo rm /usr/share/polkit-1/actions/org.freedesktop.color.policy
sudo adduser
sudo usermod -aG sudo,adm
Now Reboot Your Server:
sudo reboot
Install Python Package’s and Postgresql
sudo apt install -y python3-pip
sudo apt install -y build-essential libssl-dev libffi-dev python3-dev
sudo apt install postgresql
Login To Postgres For Generated User and Table :
sudo -u postgres psql
Create Explorer Bitcoin On Python With Flask and Postgresql
Create Database and Import All Address with Balance On Table For This Node:
CREATE USER btchunt WITH CREATEDB LOGIN ENCRYPTED PASSWORD 'ENTER_PASSWORD_HERE';
CREATE DATABASE btchunt;
GRANT ALL PRIVILEGES ON ALTER USER btchunt with encrypted password ;
DATABASE btchunt TO btchunt;
psql -U btchunt -h localhost
CREATE TABLE BTCHUNT(
address VARCHAR(80) not null,
balance VARCHAR(30) not null
);
CREATE INDEX index_btchunt ON BTCHUNT (address, balance);
Now Install PGADMIN4 and Config For Node:
sudo apt install curl
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
sudo apt install pgadmin4 -y
sudo /usr/pgadmin4/bin/setup-web.sh
sudo systemctl start postgresql.service
sudo nano /etc/postgresql/12/main/postgresql.conf
sudo bash -c "echo host all all 0.0.0.0/0 md5 >> /etc/postgresql/14/main/pg_hba.conf"
sudo ufw allow 5432/tcp
sudo ufw allow 3333/tcp
sudo systemctl restart postgresql
Flask Node Config and Setup
Create Virtualenv For Running Script INDEX on Server and Running FLASK:
sudo apt install python3-venv -y
python3 -m venv btchunt
source btchunt/bin/activate
pip install flask
pip install psycopg2-binary
pip install waitress
set FLASK_APP=app.py
export FLASK_APP=app.py
export FLASK_ENV=development
nano templates/base.html
sudo nano postgresql.conf
flask run --host=0.0.0.0
https://mmdrza.com/products/
https://mmdrza.com/private-key-wallet-the-ultimate-guide/