I will give the steps for Ubuntu and Centos, as I have done both, they are very similar, and it might help someone else.
- Step 1 is to ensure that you have the build-essential package installed. This includes gcc, make, etc.
- Install dev headers for other libraries that are used by Postgres/Postgis. This includes libxml, json-c, geos, proj4 and gdal.
- Get Postgres source and unzip
- Get Postgis.
git clone https://github.com/postgis/postgis.git postgis.git
Ubuntu:
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
Centos:
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/
./configure 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
make
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;
Or
ALTER Extension Postgis UPDATE;