Skip to content

Instantly share code, notes, and snippets.

@dnfehren
Created July 31, 2012 16:53
Show Gist options
  • Save dnfehren/3218406 to your computer and use it in GitHub Desktop.
Save dnfehren/3218406 to your computer and use it in GitHub Desktop.
postgres install instructions, not really a shell script
#get rid of anything from a mis-installed version
sudo apt-get --purge remove postgres*
sudo rm -rf /var/lib/postgresql
sudo deluser -remove-all-files postgres
#install the packages
sudo apt-get install postgresql-9.1
sudo apt-get install pgadmin3 phppgadmin
#shutdown postgres database server
sudo /etc/init.d/postgresql stop
#to change to postgres user, can't change back though
#sudo su postgres
sudo mkdir /home/postgres
sudo mkdir /home/postgres/data
sudo chown postgres:postgres /home/postgres/data
sudo chmod 0700 /home/postgres/data
#change data directory in postgresl.conf file, this prevents
# the /var partition from filling up
sudo nano /etc/postgresql/9.1/main/postgresql.conf
WILL_LOOK_LIKE data_directory = '/var/lib/postgresql/9.1/main'
SHOULD_LOOK_LIKE data_directory = '/home/postgres/data'
#uncomment for localhost access
SHOULD_LOOK_LIKE listen_addresses = 'localhost'
#as postgres user initialize data collection
/usr/lib/postgresql/9.1/bin/initdb -D /home/postgres/data
#make new ssl certificat
#http://ubuntuforums.org/showthread.php?t=735020
cd /home/postgres/data
openssl req -new -text -out server.req
openssl rsa -in privkey.pem -out server.key
rm privkey.pem
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod og-rwx server.key
chown postgres:postgres server.key
#restart the database server as dnfehren
sudo /etc/init.d/postgresql start
#as postgres user create user with same name as dnfehren
createuser -s -U postgres
#>then> dnfehren
#as postgres user - this is here allow access by pgadmin3
#change pg_hba.conf local setting from peer to md5
ALTER USER dnfehren WITH ENCRYPTED PASSWORD 'virtual';
GRANT ALL PRIVILEGES ON DATABASE template1 TO dnfehren;
#postgres linux user, postgres postgres user, dnfehren linux user and dnfehren postgres user all have same pw
#then create the dnfehren base database
createdb dnfehren -O dnfehren
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment