web123456

alpine compile and install postgresql16.4

Decompress the source code compressed file of postgresql16.4
Create postgres users and groups
Use addgroup and adduser
addgroup -g 1001 postgres
adduser -G postgres postgres
Copy to
mv postgresql-16.4/* /home/postgres/postgresql16.4/
Change directory all
chown -R postgres:postgres   /home/postgres/postgresql16.4
Compile to by default
/usr/local/pgsql directory
Create this directory
mkdir -p /usr/local/pgsql
Change users
chown -R postgres:postgres /usr/local/pgsql
Switch users
su - postgres
Go to the directory
./configure
hint
configure: error: ICU library not found
If you have ICU already installed, see for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.
Install the iicu package
apk add icu-dev
Configure again
hint
configure: error: readline library not found
Install the corresponding readline package
apk add readline-dev
hint
configure: error: zlib library not found
Install
apk add zlib-dev
again
./configure
Compilation
make all 
Install
make install
The installation is complete.
Edit environment variables
write
vim
Fill in the content, note that alpine needs to be path added to the /bin directory, otherwise it will cause ls to be unusable.

export PGPORT=5432

export PGDATA=/home/postgres/data

export LANG=en_US.utf8

export PGHOME=/usr/local/pgsql

export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH

export PATH=$PGHOME/bin:/usr/bin:/usr/local/sbin:/bin:

export MANPATH=$PGHOME/share/man:/share/man:

Apply environment changes
source
Initialize the database

initdb -D $PGDATA --encoding=UTF8 --locale=en_US.UTF8 -U postgres

Warning is prompted, it doesn’t matter.

 no usable system locales were found

Change and configure the connection.
pg_ctl start