login community faq
0
3

I know there is a private PostgreSQL instance install guide, but I need to install the a local PostgreSQL instance with the PostGIS extensions. How?

Note: If you only need PostgreSQL plus PostGIS for your project, then you do not need to follow this guide. PostgreSQL is already available on our servers, and PostGIS can be installed by the WebFaction Support team on your databases for you - just open a support ticket and let us know which database(s) you'd like to have the PostGIS extensions installed on.

This guide is only needed when you need a private PostgreSQL instance, and also want the PostGIS extensions installed locally on that private instance. This is usually done because you also want to then install additional geospatial libraries (like the latest version of proj4) thereafter, in addition to PostGIS.

asked Aug 16 '12 at 00:06

ryans's gravatar image

ryans ♦♦
28411420

edited Oct 11 '12 at 04:48

Hi, I do need proj4 in order to install GeoDjango. Is it possible to use Webfaction provided PostgreSQL + PostGIS and have my own proj4 installation,say, on $HOME/lib ? I really prefer to use yours managed server instead of mine :-)

Or is there other way to have GeoDjango installed?

Thanks,

Mário

(Aug 30 '12 at 11:50) Mario Mario's gravatar image

PROJ is already installed on our servers, here are the current specs for the CentOS 6 machine using SELECT PostGIS_full_version();

1
POSTGIS="1.5.3" GEOS="3.3.5-CAPI-1.7.5" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.6" USE_STATS

If you need a different version of PROJ, you will need to install your own version PostgreSQL and PostGIS.

(Aug 30 '12 at 12:22) timg ♦♦ timg's gravatar image

wow! I think this is enough! I'll open a ticket to get a postgis enabled database and start the tests.

Thanks Mário

(Aug 30 '12 at 12:41) Mario Mario's gravatar image

Here is an installation guide for PostgreSQL with the PostGIS extensions.

Like the related PostgreSQL Install Guide, you still need to create a new Custom Application (listening on port) in the control panel called "pgport" to reserve a port. Enter it as a shell variable:

1
export PGPORT=35270

You can run these commands individually, or you can paste them into a shell script and run it as

1
bash build_psql.sh | tee build_psql.log

Either way, you may want to run it in a screen session.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash

mkdir -p $HOME/bin $HOME/lib $HOME/src $HOME/tmp

export TMPDIR=$HOME/tmp
export PATH="$HOME/bin:$PATH"
export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
export LIBRARY_PATH="$HOME/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"

############################################################
# CARTODB COMPLETE INSTALL - DEPENDENCIES & INSTALL PRIORITY
############################################################
# PROGRAM:          VERSION:    NOTES:
# ----------------------------------------------------------
# GDAL              (1.9.0)     http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
# GEOS              (3.3.1)     http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
# Postgres          (9.1.x)     http://www.postgresql.org/ftp/source/v9.1.3/
# PostGIS           (2.0)       http://postgis.refractions.net/download

############################################################
# GDAL (1.9.0)
# http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
############################################################
cd ~/src
wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
tar -xzf gdal-1.9.0.tar.gz
cd gdal-1.9.0
./configure --prefix=$HOME
make        # 15m
#make check
make install

############################################################
# GEOS (3.3.1)
# http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
############################################################
cd ~/src
wget http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
tar -xjf geos-3.3.1.tar.bz2
cd geos-3.3.1
CFLAGS="-m64 $CFLAGS" CPPFLAGS="-m64 $CPPFLAGS" CXXFLAGS="-m64 $CXXFLAGS" \
    FFLAGS="-m64 $FFLAGS" LDFLAGS="-m64 -L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
    ./configure --prefix=$HOME
make           # 4m 20s
#make check
make install

############################################################
# Postgres (9.1.3)
# http://www.postgresql.org/ftp/source/v9.1.3/
############################################################
cd ~/src
wget http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.gz
tar -xzf postgresql-9.1.3.tar.gz
cd postgresql-9.1.3
CPPFLAGS="-I$HOME/include $CPPFLAGS" LDFLAGS="-L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
    ./configure PYTHON="${PYTHON}" --prefix=$HOME --with-pgport=$PGPORT --with-python --disable-thread-safety
make        # 3m 30s
#make check
make install

############################################################
# PostGIS (1.5.3)
# http://postgis.refractions.net/download
############################################################
cd ~/src
wget http://postgis.refractions.net/download/postgis-1.5.3.tar.gz
tar -xzf postgis-1.5.3.tar.gz
cd postgis-1.5.3
CPPFLAGS="-I$HOME/include $CPPFLAGS" LDFLAGS="-L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
    ./configure --prefix=$HOME \
                --with-gdalconfig=$HOME/bin/gdal-config \
                --with-geosconfig=$HOME/bin/geos-config \
                --with-jsondir=$HOME \
                --with-projdir=$HOME \
                --with-pgconfig=$HOME/bin/pg_config
make        # 50s
### make check     # can't test PostGIS until you have a database with PostGIS installed up and running.
make install

Okay, PostgreSQL should now be installed. After installation, you have some manual post-install setup and configuration to do:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#####################
# Post Installation #
#####################

# First, make sure that we're using the correct "psql", "createuser", and "createdb" commands:
export PATH="$HOME/bin:$PATH"
hash -r

# Add it to $HOME/.bashrc to make this permanent
echo 'export PATH="$HOME/bin:$PATH"' >> $HOME/.bashrc

# Set up DB location
mkdir $HOME/pgsql
$HOME/bin/initdb -D $HOME/pgsql/data

# Start postgresql server
$HOME/bin/postgres -D $HOME/pgsql/data >> $HOME/pgsql/log 2>&1 &

# Create the 'postgres' superuser
createuser -s postgres -P

# Create a database 'mydb'
createdb 'mydb'

# Now, connect to it (Use Ctrl-D to exit)
psql -U postgres mydb

Hope that helps!

answered Aug 16 '12 at 00:15

ryans's gravatar image

ryans ♦♦
28411420

edited Aug 30 '12 at 05:44

Ryan, if you could add pgrouting to these instructions you would be my hero. I've been fighting with getting it installed for several days now. Your guide for Postgres/PostGIS was great though, so thank you for writing it.

(Dec 29 '12 at 22:32) jimmit jimmit's gravatar image

The build instructions for pgRouting look really simple and well-written, so yeah I'd be happy to include it when time permits.

(Dec 29 '12 at 23:01) ryans ♦♦ ryans's gravatar image

It doesn't work. It seems that pgRouting is broken, and the maintainers need to fix it, although it's also possible that I'm doing something wrong.

Specifically, the installation fails with a boost_astar function interface error in pgrouting/core/src/astar_boost_wrapper.cpp.

That seems to indicate that there's a problem with astar_search.hpp. I know that's being found though because $HOME/include/boost/graph/astar_search.hpp exists and the install confirms that it's finding boost in $HOME/include.

It's possible that pgRouting is simply not compatible with Boost 1.52.0, and you can try an older version perhaps.

If you're still interested in the install, it should look something like this:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# standard env vars
export TMPDIR=$HOME/tmp
export PATH="$HOME/bin:$PATH"
export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
export LIBRARY_PATH="$HOME/lib:$LIBRARY_PATH"
export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"

# boost is a C++ library, so we need this too:
export CPLUS_INCLUDE_PATH="$HOME/include:$CPLUS_INCLUDE_PATH"

############################################################
# Boost (1.52)
# http://sourceforge.net/projects/boost/files/
############################################################
cd ~/src
wget 'http://downloads.sourceforge.net/project/boost/boost/1.52.0/boost_1_52_0.tar.bz2'
tar -xjf boost_1_52_0.tar.bz2
cd boost_1_52_0
bash bootstrap.sh --prefix=$HOME
./b2 --prefix=$HOME
mv ./boost $HOME/include/
mv ./stage/lib $HOME/lib/boost

############################################################
# GAUL (0.1849-0)
# http://gaul.sourceforge.net/downloads.html
############################################################
cd ~/src
wget 'http://prdownloads.sourceforge.net/gaul/gaul-devel-0.1849-0.tar.bz2?download'
tar -xjf gaul-devel-0.1849-0.tar.bz2 
cd gaul-devel-0.1849-0
./configure --prefix=$HOME --enable-slang=no
make
make install

############################################################
# cmake (2.8.10)
# http://www.cmake.org/cmake/resources/software.html
############################################################
cd ~/src
wget 'http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz'
tar -xzf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./configure --prefix=$HOME
make
make install

# ############################################################
# # CGAL (3.3.1)
# # http://www.cgal.org/download.html
# ############################################################
# cd ~/src
# wget 'https://gforge.inria.fr/frs/download.php/10694/CGAL-3.3.1.tar.gz'
# tar -xzf CGAL-3.3.1.tar.gz
# cd CGAL-3.3.1
# ./install_cgal --prefix=$HOME --with-boost=n --without-autofind -ni /usr/bin/g++
# export CGAL_MAKEFILE="/home/testweb310/share/cgal/cgal.mk"

############################################################
# GNU MP Bignum Library 5.0.2
############################################################
cd $HOME/src
wget 'http://mirror.ryansanden.com/gcc-4.6/gmp-5.0.2.tar.bz2'
tar -xjf gmp-5.0.2.tar.bz2
cd gmp-5.0.2
CPPFLAGS=-fexceptions ./configure --prefix=$HOME --enable-cxx
make          # 2 min
make install

############################################################
# GNU MFPR Library 3.1.0
############################################################
cd $HOME/src
wget 'http://mirror.ryansanden.com/gcc-4.6/mpfr-3.1.0.tar.bz2'
wget 'http://mirror.ryansanden.com/gcc-4.6/mpfr-3.1.0-allpatches.patch'
tar -xjf mpfr-3.1.0.tar.bz2
cd mpfr-3.1.0
patch -N -Z -p1 < ../mpfr-3.1.0-allpatches.patch
./configure --prefix=$HOME --with-gmp=$HOME/
make          # 1.5 min
make install

############################################################
# CGAL (4.1)
# http://www.cgal.org/download.html
############################################################
cd ~/src
wget 'https://gforge.inria.fr/frs/download.php/31640/CGAL-4.1.tar.bz2'
tar -xjf CGAL-4.1.tar.bz2
cd CGAL-4.1
cmake -DBOOST_ROOT="$HOME" \
      -DWITH_GMP="y" -DGMP_INCLUDE_DIR="$HOME/include" -DGMP_LIBRARIES_DIR="$HOME/lib" \
      -DMPFR_INCLUDE_DIR="$HOME/include" -DMPFR_LIBRARIES_DIR="$HOME/lib" \
      -DCMAKE_INSTALL_PREFIX="$HOME" .
make
make install

############################################################
# pgrouting (1.05)
# http://pgrouting.org/download.html
############################################################
export CPPFLAGS="-I$HOME/include $CPPFLAGS"
export LDFLAGS="-L$HOME/lib $LDFLAGS"

cd ~/src
git clone git://github.com/pgRouting/pgrouting.git pgrouting
cd pgrouting
mkdir -p $HOME/share/pgrouting

sed -i "s^/usr/share/pgrouting^$HOME/share/pgrouting^g" CMakeLists.txt
sed -i "s^/usr^$HOME^g" ./cmake/FindCGAL.cmake
sed -i "s^/usr^$HOME^g" ./cmake/FindGAUL.cmake
sed -i "s^/usr^$HOME^g" ./cmake/FindPostgreSQL.cmake
cmake -DPOSTGRESQL_EXECUTABLE="$HOME/bin" \
      -DBoost_INCLUDE_DIR="$HOME/include" \
      -DBOOST_THREAD_LIBRARIES="$HOME/lib" \
      -DWITH_TSP="ON" -DWITH_DD="ON" -Wno-dev .
make

# also tried this instead of last three sed lines:
# 
# cmake -DPOSTGRESQL_INCLUDE_DIR="$HOME/include/postgresql/server" -DPOSTGRESQL_LIBRARIES="$HOME/lib" \
#       -DPOSTGRESQL_EXECUTABLE="$HOME/bin" \
#       -DBoost_INCLUDE_DIR="$HOME/include" \
#       -DBOOST_THREAD_LIBRARIES="$HOME/lib" \
#       -DGAUL_INCLUDE_DIR="$HOME/include" -DGAUL_LIBRARIES="$HOME/lib" -DGAUL_UTIL_LIBRARIES="$HOME/lib" \
#       -DCGAL_INCLUDE_DIR="$HOME/include" -DCGAL_LIBRARIES="$HOME/lib" \
#       -DSQL_INSTALL_PATH="$HOME/share/postlbs" \
#       -DLIB_DIR="$HOME/lib" \
#       -DWITH_TSP="ON" -DWITH_DD="ON" -Wno-dev .
(Dec 30 '12 at 20:54) ryans ♦♦ ryans's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×69
×7

Asked: Aug 16 '12 at 00:06

Seen: 1,228 times

Last updated: Dec 30 '12 at 21:01

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited