Though PostgreSQL 9.3 has released, there are people who still uses PostgreSQL 9.2 in combination with PostGIS 2.0. It is fairly easy to install and set-up PostgreSQL 9.2 in Ubuntu. It can be done in no time using any package manager like aptitude or synaptic. But the PostGIS 2.0 version available in apt repository has some compatibility problems and it is hard to install(at least for me). So in this post we will try the alternate way – install from source. So let’s start with the PostgreSQL 9.2 installation.
1. Install PostgreSQL 9.2
- Find out your Ubuntu release
Run the following command in your terminal to get your Ubuntu release name(codename).
You will get something like precise (in my case) or wheezy. Make a note of it.
- Add PostgreSQL repository to source list
In the following command replace the codename with the release name, which you got from step 1, and run.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ codename-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
- Import PostgreSQL repository key
Use the following command to import the repository key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- Install PostgreSQL 9.2
sudo apt-get update sudo apt-get upgrade sudo apt-get -y install python-software-properties sudo apt-get install postgresql-9.2 pgadmin3
2. Install PostGIS 2.0
Now it is time to install PostGIS 2.0.6. Prior to build and install PostGIS it is better to build GEOS, which is required for PostGIS raster topology.
- Build GEOS 3.3.9
The following commands will download make and install the GEOS 3.3.9. Run it one by one.
wget http://download.osgeo.org/geos/geos-3.3.9.tar.bz2 tar xfj geos-3.3.9.tar.bz2 cd geos-3.3.9 ./configure make sudo make install
- Build PostGIS 2.0.6
Run the following commands in your home folder.
wget http://download.osgeo.org/postgis/source/postgis-2.0.6.tar.gz tar xfz postgis-2.0.6.tar.gz cd postgis-2.0.6 ./configure make sudo make install sudo ldconfig sudo make comments-install
3. Set Up PostgreSQL to use with PgAdmin
You may follow the step 4 and 5 of the following post to make necessary settings so that you can access your server using PgAdmin3: Accessing Database from Terminal/pgAdmin
4. Enable PostGIS for the Database
Now that we have made all the necessary installations and configurations, let’s to try to enable PostGIS to your postgis Databae.
- Connect to your server and open a query browser and execute:
CREATE EXTENSION postgis;
- Run the following function to verify that PostGIS is installed correctly:
It will return something like:
“2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1”
So, we finished with Installation of PostgreSQL 9.2 with PostGIS 2.0. In case of any problems please leave a comment here!
Latest posts by Vipin Raj (see all)
- Relation Between Games and Studies [Infographics] - April 3, 2017
- How to Access Ubuntu PC Files From Your Android Phone - February 7, 2016
- How to Install BSNL EVDO in Ubuntu / Mint in 3 Minutes - January 27, 2016