Installing PostGIS from Source
Strongly recommend using yum / apt commands to install PostGIS from official PostgreSQL binary repositories.
1. Installation Environment
- CentOS 7
- PostgreSQL10
- PostGIS2.4
- PGROUTING2.5.2
2. PostgreSQL10 Installation
2.1 Determine System Environment
2.2 Install Correct RPM Package
Different systems use different RPM sources. You can get the appropriate platform links from http://yum.postgresql.org/repopackages.php.
2.3 Check if RPM Package is Correctly Installed
2.4 Install PostgreSQL
You can choose to install the appropriate RPM packages based on your needs.
2.5 Start Service
By default, PostgreSQL installation directory is /usr/pgsql-10/, data directory is /var/lib/pgsql/, and the system creates a default user postgres.
3. PostGIS Installation
If you encounter errors like:
You can try to resolve it with:
yum -y install epel-release
4. FDW Installation
5. pgRouting Installation
6. Verification Testing
Compilation Tools
These tools are generally included with the system.
- GCC and G++, version at least
4.x. - GNU Make, CMake, Autotools
- Git
On CentOS, install directly with sudo yum install gcc gcc-c++ git autoconf automake libtool m4.
Required Dependencies
PostgreSQL
PostgreSQL is the host platform for PostGIS. Here we use 10.1 as an example.
GEOS
GEOS is the abbreviation for Geometry Engine, Open-Source, a C++ version of the geometry library and PostGIS’s core dependency.
PostGIS 2.4 uses some new features from GEOS 3.7. However, as of now, the latest version officially released by GEOS is 3.6.2. GEOS version 3.7 can be obtained through Nightly snapshot. So currently, if you want to use all new features, you need to compile and install GEOS 3.7 from source.
Proj
Provides coordinate projection support for PostGIS. Current latest version is 4.9.3: Download
JSON-C
Currently used for importing GeoJSON format data. The ST_GeomFromGeoJson function uses this library.
Compiling json-c requires autoconf, automake, libtool.
LibXML2
Currently used for importing GML and KML format data. Functions ST_GeomFromGML and ST_GeomFromKML depend on this library.
Currently available from this download server. Current version used is 2.9.7.
GDAL
SFCGAL
SFCGAL is an extended wrapper for CGAL. Although it’s optional, many functions are commonly used, so installation is needed here. Download page
SFCGAL has many dependencies, including CMake, CGAL, Boost, MPFR, GMP, etc. Among these, CGAL was manually installed above. Here we still need to manually install BOOST.
Boost
Boost is a common C++ library that SFCGAL depends on. Download page
