Multiple versions of PostGIS and PgRouting on CentOS 7 I'm trying to install multiple versions of PostGis and PgRouting in the same instance of PostgreSQL v9.6, using CentOS 7.5.

I've been fighting with dependencies and shared libraries, to make all working.

So the question is, which is the best way to manage de dependencies versions? If I install a major dependency version, old Postgis version still working?

Some dependencies are: GDAL, GEOS, Proj4, etc.

I've been organizing them in folders, with contains subfolders with the version of the dependency, using --prefix=path/v3.0.0 on ./configure script during the depency installation.

Example: Folder -> GEOS - Subfolders: v3.0.0, v3.4.0, etc.

After that, when i want to install any PostGIS version, I use ./configure to use any dependency absolute path.

Example: ./configure --with-pgconfig=path --with-gdal=path/version --with-proj4=path/version ...

But I'm not sure that is a right way.

Any suggestion is welcome to clear my mind.
It won't work to install several versions of PostGIS in the same PostgreSQL software directory, since the resulting shared objects will have the same name. Using a different --prefix is not enough, since most of PostGIS is not installed there, but in the PostgreSQL software directory.

So you should make a copy of your PostgreSQL software directory and install the different PostGIS versions in different directories.

If you really need different versions of Proj, GDAL etc. (why?), things become difficult, and you'd have to use a different LD_LIBRARY_PATH for each instance.

But perhaps it is much simpler, since the recent versions of PostGIS are binary compatible and come with installation scripts for several versions.

So maybe you can do with just installing the most recent PostGIS version and using different versions in different databases:

CREATE EXTENSION postgis VERSION 2.4.0;