Skip to content

Instantly share code, notes, and snippets.

@crofty
Created December 2, 2009 21:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crofty/247621 to your computer and use it in GitHub Desktop.
Save crofty/247621 to your computer and use it in GitHub Desktop.
Postgres setup
# Postgres install on ubuntu
sudo apt-get install postgresql
# Log in with
sudo -u postgres psql postgres
# change password by issuing
\password postgres
# create databases with
sudo -u postgres createdb mydb
# Install the gem
sudo gem install postgres -- --with-pgsql-dir=/usr/local/pgsql
####### Enable remote access
sudo vi /etc/postgresql/8.3/main/pg_hba.conf
# append the line (with the IP that you want to be able to access the DB)
host all all XXX.XXX.XXX.XXX/0 trust
sudo vi /etc/postgresql/8.3/main/postgresql.conf
# Change listen_addresses='localhost' to
listen_addresses='localhost, XXX.XXX.XXX.XXX' # use '*' for all addresses
sudo /etc/init.d/postgresql-8.3 restart
# Setup IP rules
sudo iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d XXX.XXX.XXX.XXX --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp -s XXX.XXX.XXX.XXX --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment