Last active
August 29, 2015 14:01
-
-
Save gullitmiranda/e9e8afc4f0804fde083a to your computer and use it in GitHub Desktop.
Install Postgresql 9.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo su | |
#### Install Postgresql 9.3 | |
# add repositories | |
echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | |
apt-get update | |
# Ensure UTF-8 | |
locale-gen en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
# Install the latest postgresql | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list | |
apt-get update | |
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes postgresql-9.3 libpq-dev | |
# Install other tools. | |
DEBIAN_FRONTEND=noninteractive apt-get install -y pwgen inotify-tools | |
sudo -u postgres psql | |
update pg_database set datistemplate=false where datname='template1'; | |
drop database Template1; | |
create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0; | |
update pg_database set datistemplate=true where datname='template1'; | |
alter user postgres password 'postgres'; | |
\q | |
service postgresql stop | |
# Clean up APT when done. | |
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
# Allow connections from anywhere. | |
sed -i -e"s/^#listen_addresses =.*$/listen_addresses = '*'/" /etc/postgresql/9.3/main/postgresql.conf | |
echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf | |
service postgresql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment