§2023-04-05


試作機器: h2Jammy.yushei.net

  1. Compile python from source
$ wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tar.xz
$ cd ..
$ tar xvf src/Python-3.11.2.tar.xz 
$ cd Python-3.11.2
$ ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
$ ./configure --enable-optimizations
$ time make -j 6 // ${nproc} + 2
real    7m24.380s
user    17m37.166s
sys     0m59.415s
  1. setup environment control
$ ./python --version
Python 3.11.2
./python -m venv ~/PYTHON-3.11.2
$ cd
$ source PYTHON-3.11.2/bin/activate
(PYTHON-3.11.2) alexlai@h2Jammy:~$ $ echo $PATH
/home/alexlai/PYTHON-3.11.2/bin:/usr/local/pgsql/bin:/home/alexlai/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

以下、 under env control

  1. Install dependencies
$ sudo apt update
$ sudo apt install libgmp3-dev libpq-dev
$ sudo apt auto-remove
  1. create a few directories where pgAdmin will store its sessions data, storage data, and logs:
sudo mkdir -p /var/lib/pgadmin4/sessions
sudo mkdir /var/lib/pgadmin4/storage
sudo mkdir /var/log/pgadmin4
sudo mkdir /var/lib/pgadmin4/azurecredentialcache


sudo chown -R alexlai:alexlai /var/lib/pgadmin4
sudo chown -R alexlai:alexlai /var/log/pgadmin4
  1. Using pip to install software
python -m pip install -U pip
Successfully installed pip-23.0.1

$ pip --version
pip 23.0.1 from /home/alexlai/PYTHON-3.11.2/lib/python3.11/site-packages/pip (python 3.11)

$ pip install pgadmin4
$ pip install gunicorn
  1. Create ~/PYTHON-3.11.2/lib/python3.11/site-packages/pgadmin4/config_local.py as, <-- new
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
SERVER_MODE = True
AZURE_CREDENTIAL_CACHE_DIR = '/var/lib/pgadmin4/azurecredentialcache' 
  1. With those configurations in place, run the pgAdmin setup script to set your login credentials:
$ python ~/PYTHON-3.11.2/lib/python3.11/site-packages/pgadmin4/setup.py