Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oshinko/ff698fade483ee3711e1ae9a1db81147 to your computer and use it in GitHub Desktop.
Save oshinko/ff698fade483ee3711e1ae9a1db81147 to your computer and use it in GitHub Desktop.
Install PostgreSQL 11 from Source Code on Amazon Linux 2
sudo yum groupinstall "Development Tools" -y
sudo yum install readline readline-devel systemd-devel -y
wget -O - https://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.bz2 | tar jxf -
cd postgresql-11.4
# ref: https://www.postgresql.org/docs/11/install-short.html
./configure --with-systemd
make
sudo make install
sudo adduser postgres
sudo passwd -d postgres
sudo mkdir /usr/local/pgsql/data
sudo chown postgres /usr/local/pgsql/data
sudo su - postgres -c "/usr/local/pgsql/bin/initdb -A trust -D /usr/local/pgsql/data"
# ref: https://www.postgresql.org/docs/11/server-start.html
sudo bash -c "cat << EOF > /etc/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)
[Service]
Type=notify
User=postgres
ExecStart=/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
ExecReload=/bin/kill -HUP \\\$MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl daemon-reload
sudo systemctl enable postgresql.service
sudo systemctl start postgresql.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment