There is postgresql-9.3-postgis-2.1 and there is postgresql-9.4-postgis-2.1. Unfortunately 9.3 is available only on trusty and 9.4 is not available on trusty (see http://packages.ubuntu.com/search?keywords=postgresql-9.3-postgis-2.1 and http://packages.ubuntu.com/search?keywords=postgresql-9.4-postgis-2.1).

So any installation instructions/script must include something along "if your OS version is...". Is there some method to simply install newest postgresql postgis package?

  • 1
    Yeah, building from source :-) I am on 14.04, but running latest Postgres, Postgis and GEOS. If you have a problem with Ubuntu packages, Centos is even worse, usually a good small number or two behind, given their innate conservatism (which is, obviously a good thing for production boxes). Based on this, I realized that if you want latest features, you need to build yourself. In my experience, so long as you build on stable versions, this is not an issue in production. Commented Feb 26, 2016 at 7:09
  • Can you recommend some build instructions for Postgres and Postgis? Commented Feb 26, 2016 at 7:59
  • 1
    Here is one attempt. Sorry, I am in a bit of a hurry. Let me know if you have issues. Commented Feb 26, 2016 at 8:40

1 Answer 1


I will give the steps for Ubuntu and Centos, as I have done both, they are very similar, and it might help someone else.

  1. Step 1 is to ensure that you have the build-essential package installed. This includes gcc, make, etc.
  2. Install dev headers for other libraries that are used by Postgres/Postgis. This includes libxml, json-c, geos, proj4 and gdal.
  3. Get Postgres source and unzip
  4. Get Postgis. git clone https://github.com/postgis/postgis.git postgis.git


sudo apt-get install build-essential
sudo apt-get install libxml2-dev
sudo apt-get install libjson-c-dev
sudo apt-get install libgdal-dev
sudo apt-get install libproj-dev 
sudo apt-get install libgeos-dev


sudo yum groupinstall "Development tools"
sudo yum install postgresql-devel.x86_64
sudo yum install libxml2-devel.x86_64
sudo yum install json-c-devel.x86_64
sudo yum install geos-devel.x86_64
sudo yum install proj-devel.x86_64
sudo yum install gdal-devel.x86_64

Unzip Postgres, cd to unzip dir, run ./configure. There are some options, and ./configure --help will show you, but in general, the defaults work well. If you are installing multiple version of Postgres, you might want to set ./configure --prefix=/path_to_install, otherwise the files will go in /usr/local/pgsql/

sudo gmake

If you have issues with libraries not being found, you might need to fiddle with ldconfig.

git clone https://github.com/postgis/postgis.git postgis.git
cd postgis.git
./configure --with-pgconfig=/usr/local/bin/pg_config
sudo make install

There are many options to Postgis configure, and you may need to set the path to geos-config and other libs, especially if you have previous versions of libs. The most important one tends to be the path to pg_config.

Then from psql prompt:

 CREATE Extension Postgis;


 ALTER Extension Postgis UPDATE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.