Skip to content

Instantly share code, notes, and snippets.

@drajathasan
Last active November 3, 2023 15:33
Show Gist options
  • Save drajathasan/516a7e701a9ac937aa66ed0591cd92a7 to your computer and use it in GitHub Desktop.
Save drajathasan/516a7e701a9ac937aa66ed0591cd92a7 to your computer and use it in GitHub Desktop.
// open your terminal
1. Download source from official website
2. Extract it into some folder
3. Do this command
cd source_of_postgres_dir
./configure
make
su
make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
// if you wanna use systemd create service file in
-> /usr/lib/systemd/system/ with this command
4. sudo nano /usr/lib/systemd/system/postgresql.service
5. fill the file with this script
[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)
[Service]
Type=simple
User=postgres
ExecStart=/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
RuntimeDirectory=postgresql
[Install]
WantedBy=multi-user.target
6. type
sudo systemctl daemon-reload
7. In Arch Linux runtime directory in /run/
8. change postgresql.conf unix socket to /run/postgresql
9. createuser -h /run/postgresql -P -s -e joe
Works well in ArchLinux and derivative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment