[GIS] How to install pgRouting on PostgreSQL 9.2 located at /opt/PostgreSQL/9.2/ on Ubuntu Server 12.10

installationpgroutingpostgresqlUbuntu

I have installed PostgreSQL 9.2 on Ubuntu Server 12.10 using one-click installer from the EnterpriseDB. Then using the StackBuilder I installed PostGIS.

Now I also want to install the pgRouting extension to my database. So far I have found instructions on the following pages:

But the last command try to install postgresql-9.1 from the apt repositories:

# sudo apt-get install postgresql-9.1-pgrouting
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libboost-thread1.49.0 libcgal9 libgeos-3.3.3 libgeos-c1 libproj0 libqt4-dbus libqt4-declarative libqt4-designer
  libqt4-help libqt4-network libqt4-opengl libqt4-script libqt4-scripttools libqt4-sql libqt4-sql-mysql
  libqt4-sql-sqlite libqt4-svg libqt4-test libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 postgis
  postgresql-9.1 postgresql-9.1-postgis postgresql-common proj-data qdbus
Suggested packages:
  proj-bin libqt4-declarative-folderlistmodel libqt4-declarative-gestures libqt4-declarative-particles
  libqt4-declarative-shaders qt4-qmlviewer libqt4-dev qt4-qtconfig oidentd ident-server locales-all osm2pgrouting
  pgrouting-workshop
The following NEW packages will be installed:
  libboost-thread1.49.0 libcgal9 libgeos-3.3.3 libgeos-c1 libproj0 libqt4-opengl postgis postgresql-9.1
  postgresql-9.1-pgrouting postgresql-9.1-postgis postgresql-common proj-data
The following packages will be upgraded:
  libqt4-dbus libqt4-declarative libqt4-designer libqt4-help libqt4-network libqt4-script libqt4-scripttools
  libqt4-sql libqt4-sql-mysql libqt4-sql-sqlite libqt4-svg libqt4-test libqt4-xml libqt4-xmlpatterns libqtcore4
  libqtgui4 qdbus

I want to install pgRouting on my existing PostgreSQL which is located at:

/opt/PostgreSQL/9.2/

I have also downloaded the source code. Following these instructions:

mkdir build
cd build
cmake -DWITH_DD=ON ..
make
sudo make install

When I run

# cmake -DWITH_DD=ON ..
-- PGROUTING_GIT_TAG: pgrouting-2.0.0
-- PGROUTING_GIT_BUILD: 0
-- PGROUTING_GIT_HASH: f26831f
-- PGROUTING_GIT_BRANCH: master
-- PGROUTING_VERSION_REVISION_NAME: f26831f master
-- PGROUTING_VERSION_REVISION_HASH: f26831f
-- UNIX=1
-- WIN32=
-- POSTGRESQL_EXECUTABLE is POSTGRESQL_EXECUTABLE-NOTFOUND
-- POSTGRESQL_PG_CONFIG is POSTGRESQL_PG_CONFIG-NOTFOUND
-- PostgreSQL not found.
CMake Error at CMakeLists.txt:122 (message):
   Please check your PostgreSQL installation.


-- Configuring incomplete, errors occurred!

I can't figure out a way to tell cmake to locate my existing PostgreSQL installation.

Any suggestions are very welcome.

Best Answer

You can't install pgrouting for PostgreSQL 9.1 into PostgreSQL 9.2. Even if you could install the package without downloading all of 9.1, it wouldn't work, it'd just be unavailable - totally invisible to Pg 9.2.

If PgRouting is not included in EDB's StackBuilder you will need to build it from source code according to the instructions on the PgRouting website. See the source code readme for guidance on this process. When compiling pgrouting, you may need to add the appropriate pg_config to the PATH, e.g:

PATH=/opt/PostgreSQL/9.2/bin:$PATH

Alternately, you could use the PGDG packages of PostgreSQL for Ubuntu instead of the EDB installer. That will get you PostGIS and PgRouting for PostgreSQL 9.2 (or 9.3) via apt-get. See http://wiki.postgresql.org/wiki/Apt . This will do a new PostgreSQL installation - it won't use your existing database in /opt, so you will need to do a pg_dump and then restore the DB if there's any data you want to keep. It won't delete or replace the DB in /opt, it'll just create a new PostgreSQL on a different port, probably 5433.

Related Question