-
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository:
deb http://apt.postgresql.org/pub/repos/apt/ YOUR_DEBIAN_VERSION_HERE-pgdg main -
Import the repository signing key, and update the package lists.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update - Install from the package manager.
apt-get install postgresql-9.5(or whatever)
Here's the documentation.
-
apt.postgresql.org has the PostGIS packages too, so...
sudo apt-get install postgresql-9.5-postgis-2.2 pgadmin3 postgresql-contrib-9.5 -
For routing:
sudo apt-get install postgresql-9.5-pgrouting -
Enable Adminpack:
# Log in to the psql console as postgres user:
sudo -u postgres psqlCREATE EXTENSION adminpack;
-- Never install PostGIS in the postgres database, create a user database.
-- You can also enable the PostGIS extension here (or with the GUI as described below):
CREATE DATABASE gisdb;
\connect gisdb;
CREATE EXTENSION postgis;
SELECT postgis_full_version();
-- Install pgRouting
CREATE EXTENSION pgrouting;
SELECT * FROM pgr_version();
\qSee http://postgis.net/install/ and http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS22UbuntuPGSQL95Apt