§2023-04-05
試作機器: h2Jammy.yushei.net
- 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
- 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
- Install dependencies
$ sudo apt update
$ sudo apt install libgmp3-dev libpq-dev
$ sudo apt auto-remove
- 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
- 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
- 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'
- Here are what these five directives do:
- LOG_FILE: this defines the file in which pgAdmin’s logs will be stored.
- SQLITE_PATH: pgAdmin stores user-related data in an SQLite database, and this directive points the pgAdmin software to this configuration database. Because this file is located under the persistent directory /var/lib/pgadmin4/, your user data will not be lost after you upgrade.
- SESSION_DB_PATH: specifies which directory will be used to store session data.
- STORAGE_DIR: defines where pgAdmin will store other data, like backups and security certificates.
- SERVER_MODE: setting this directive to True tells pgAdmin to run in Server mode, as opposed to Desktop mode.
- 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