PostGIS Install and Cloning Ubuntu Systems Notes

[cc lang=’bash’ ]sudo apt-get remove –purge[/cc]

[cc lang=’bash’ ]apt-get install deborphan debfoster
deborphan –guess-all[/cc]

[cc lang=’bash’ ]apt-get autoremove
sudo apt-get remove –purge postgresql-client
sudo apt-get remove –purge postgresql-client-8.4
sudo apt-get remove –purge postgresql-client-common
apt-get clean[/cc]

still didn’t work.
[cc lang=’bash’ ]jcz@dell390:/usr/local/src/postgis-1.5.2$ ls -l /usr/bin/pg*
-rwxr-xr-x 1 root root 26260 2011-02-02 03:56 /usr/bin/pg
-rwxr-xr-x 1 root root 25912 2011-04-20 10:27 /usr/bin/pg_config
-rwxr-xr-x 1 root root 13860 2010-07-06 20:21 /usr/bin/pgrep
jcz@dell390:/usr/local/src/postgis-1.5.2$ sudo rm /usr/bin/pg_config[/cc]

[cc lang=’bash’ ]sudo ln -s /usr/local/pgsql/bin/pg_config /usr/bin/pg_config
apt-get install libxml2-dev[/cc]

and finally got
[cc lang=’bash’ ]PostGIS is now configured for i686-pc-linux-gnu

————– Compiler Info ————-
C compiler:           gcc -g -O2
C++ compiler:         g++ -g -O2

————– Dependencies ————–
GEOS config:          /usr/local/bin/geos-config
GEOS version:         3.2.2
PostgreSQL config:    /usr/bin/pg_config
PostgreSQL version:   PostgreSQL 9.0.4
PROJ4 version:        47
Libxml2 config:       /usr/bin/xml2-config
Libxml2 version:      2.7.7
PostGIS debug level:  0

——– Documentation Generation ——–
xsl style sheets:
convert:           [/cc]

[cc lang=’bash’ ]#!/bin/sh
sudo ln -s /usr/local/pgsql/bin/createlang /usr/bin/createlang
sudo ln -s /usr/local/pgsql/bin/dropdb /usr/bin/dropdb
sudo ln -s /usr/local/pgsql/bin/initdb /usr/bin/initdb
sudo ln -s /usr/local/pgsql/bin/pg_ctl /usr/bin/pg_ctl
sudo ln -s /usr/local/pgsql/bin/createdb /usr/bin/createdb
sudo ln -s /usr/local/pgsql/bin/createuser  /usr/bin/createuser
sudo ln -s /usr/local/pgsql/bin/pg_dump /usr/bin/pg_dump
sudo ln -s /usr/local/pgsql/bin/pgsql2shp /usr/bin/pgsql2shp
sudo ln -s /usr/local/pgsql/bin/pg_upgrade /usr/bin/pg_upgrade
sudo ln -s /usr/local/pgsql/bin/shp2pgsql /usr/bin/shp2pgsql

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

make install
createlang plpgsql yourtestdatabase
psql -d yourtestdatabase -f postgis/postgis.sql
psql -d yourtestdatabase -f spatial_ref_sys.sql[/cc]

how to generate a list of installed packages and use it to reinstall packages
[cc lang=’bash’ ]sudo apt-get update
sudo apt-get dist-upgrade
sudo dpkg –get-selections | grep -v deinstall | awk ‘{print $1}’ > 164.ubuntu-files_b.txt
sudo cat 164.ubuntu-files_b.txt | xargs sudo aptitude install[/cc]

NOTE: WordPress interprets two dashes (- -) as one dash (–). When you’re putting this into your CLI, make sure it’s dropping two dashes ‘- -’ without the space between them.


Update 20-Aug-2011

One liners install process instructions for Ubuntu 11



sudo apt-get install libreadline6-dev zlib1g-dev libxml2 libxml2-dev bison openssl libssl-dev
sudo apt-get yum install -y

mkdir -p /usr/local/src

cd /usr/local/src

tar zxvf postgresql-8.3.7.tar.gz

cd postgresql-8.3.7

./configure –with-openssl –enable-integer-datetimes


make install

cd /usr/local/src/postgresql-8.3.7/contrib/

make all

make install

cp /usr/local/src/postgresql-8.3.7/contrib/start-scripts/linux /etc/init.d/postgresql

chmod 775 /etc/init.d/postgresql

update-rc.d /etc/init.d/postgresql defaults

adduser postgres -d /usr/local/pgsql

echo ‘PATH=$PATH:/usr/local/pgsql/bin; export PATH’ > /etc/profile.d/
echo ‘MANPATH=$MANPATH:/usr/local/pgsql/man; export MANPATH >> /etc/profile.d/

chmod 775 /etc/profile.d/
chmod 775 /etc/profile.d/

mkdir -p /var/log/pgsql
chown -R postgres:postgres /var/log/pgsql/

mkdir /usr/local/pgsql/data

chown -R postgres:postgres /usr/local/pgsql/data

su – postgres

/usr/local/pgsql/bin/initdb -U postgres -E=UTF8 /usr/local/pgsql/data

These steps should be done as the postgres user.  As root, issue: `su – postgres` (no password needed), the postgresql.conf and pg_hba.conf configuration files are located in /usr/local/pgsql/data/

Using the ‘nano‘ editor, (or vi), modify the postgresql.conf to allow the installation to listen for remote connections. Also, while we’re in here let’s configure the logging to create the log file in /var/log/pgsql/. The main cause of not being able to connect to a PostgreSQL database is because of a misconfiguration in this file.

listen_addresses = ‘*’
port = 5432
log_destination = ‘stderr’
logging_collector = on
log_directory = ‘/var/log/pgsql/’
log_filename = ‘postgresql-%Y-%m-%d’
log_line_prefix = ‘ %t %d %u ‘

Now, edit the pg_hba.conf and configure some network rules. Add the line in red to match your LAN address range. Set access from other computers to use md5 authentication. You can also set the other methods to md5, (and others) but for managability, leave the local connections set to ‘trust’ for now. The order of rules in this file matters.

# “local” is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all trust
host all all md5
# IPv6 local connections:
host all all ::1/128 trust

/etc/init.d/postgresql start


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.