最小化安装centos7
yum install libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel openssl openssl-devel openldap openldap-devel readline readline-devel pam pam-devel systemd-devel tcl-devel -y
groupadd postgres
useradd -g postgres postgres
passwd postgres(新建用户密码)
cd /
mkdir -p postgres-data
chmod +w postgres-data
chown -R postgres:postgres /postgres-data
./configure --prefix=/usr/local/pgsql --with-tcl --with-systemd --with-gssapi --with-pam --with-ldap --with-openssl --with-libxml --enable-thread-safety --with-zlib --with-selinux --with-readline
su - postgres(切换用户)
/usr/local/pgsql/bin/initdb -D /postgres-data/(初始化数据库)
拷贝启动脚本
cd (源码包)/contrib/start-scripts/linux /etc/init.d/postgresql
chmod +x /etc/init.d/postgresql
注意:有部分坑,比如文件夹不存在,pgdata路径错误的,自己稍稍修改,祝君成功!