Install PostGIS-2.1.8
Version:
Proj-4.8.0.tar.gz
Geos-3.4.2.tar.bz2
Gdal-2.0.1.tar.gz
PostGIS-2.1.82.1.8
Prerequisites:
Proj,geos,gdal. PostGIS must be installed before installing proj,geos,gdal.
Install proj4
[root@Darren2 tools] # wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
[root@Darren2 tools] # tar xf proj-4.8.0.tar.gz
[root@Darren2 tools] # cd proj-4.8.0
[root@Darren2 proj-4.8.0] #. / configure-prefix=/usr/local/pgsql/plugin/proj
[root@Darren2 proj-4.8.0] # make & & make install
Waiting for about 1min
# configure and load dynamic link libraries:
[root@Darren2 proj-4.8.0] # vim / etc/ld.so.conf.d/proj-4.8.0.conf
/ usr/local/pgsql/plugin/proj/lib
[root@Darren2 proj-4.8.0] # ldconfig
Install geos
[root@Darren2 tools] # wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
[root@Darren2 tools] # bzip2-d geos-3.4.2.tar.bz2
[root@Darren2 tools] # tar xf geos-3.4.2.tar
[root@Darren2 geos-3.4.2] #. / configure-prefix=/usr/local/pgsql/plugin/geos
.
Swig: false
Python bindings: false
Ruby bindings: false
PHP bindings: false
# these are negligible
[root@Darren2 geos-3.4.2] # make & & make install
Waiting for about 5min
# configure and load dynamic link libraries:
[root@Darren2 geos-3.4.2] # vim / etc/ld.so.conf.d/geos-3.4.2.conf
/ usr/local/pgsql/plugin/geos/lib
[root@Darren2 geos-3.4.2] # ldconfig
Install gdal
[root@Darren2 tools] # wget http://download.osgeo.org/gdal/2.0.1/gdal-2.0.1.tar.gz
[root@Darren2 tools] # tar xf gdal-2.0.1.tar.gz
[root@Darren2 tools] # cd gdal-2.0.1
[root@Darren2 gdal-2.0.1] #. / configure-prefix=/usr/local/pgsql/plugin/gdal
[root@Darren2 gdal-2.0.1] # make & & make install
Waiting for about 15min
# configure and load dynamic link libraries:
[root@Darren2 gdal-2.0.1] # vim / etc/ld.so.conf.d/gdal-2.0.1.conf
/ usr/local/pgsql/plugin/gdal/lib
[root@Darren2 gdal-2.0.1] # ldconfig
Install PostGIS
[root@Darren2 tools] # wget http://download.osgeo.org/postgis/source/postgis-2.1.8.tar.gz
[root@Darren2 tools] # tar xf postgis-2.1.8.tar.gz
. / configure-- help parameter:
-- prefix=PREFIX install architecture-independent files in PREFIX [/ usr/local]
-- with-pgconfig=FILE specify an alternative pg_config file
-- with-geosconfig=FILE specify an alternative geos-config file
-- with-projdir=PATH specify the PROJ.4 installation directory
-- without-raster Disable the raster extension
[root@Darren2 postgis-2.1.8] #. / configure-- prefix=/usr/local/pgsql/plugin/postgis\
-- with-pgconfig=/usr/local/pgsql/bin/pg_config\
-- with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config\
-- with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config\
-- with-projdir=/usr/local/pgsql/plugin/proj
.
PostGIS is now configured for x86_64-unknown-linux-gnu
-Compiler Info-
C compiler: gcc-g-O2
C++ compiler: Gmail +-g-O2
SQL preprocessor: / usr/bin/cpp-w-traditional-cpp-P
-Dependencies-
GEOS config: / opt/geos-3.4.2/bin/geos-config
GEOS version: 3.4.2
GDAL config: / usr/local/bin/gdal-config
GDAL version: 2.0.1
PostgreSQL config: / usr/local/pgsql/bin/pg_config
PostgreSQL version: PostgreSQL 9.6.3
PROJ4 version: 48
Libxml2 config: / usr/bin/xml2-config
Libxml2 version: 2.7.6
JSON-C support: no
PostGIS debug level: 0
Perl: / usr/bin/perl
-Extensions-
PostGIS Raster: enabled
PostGIS Topology: enabled
SFCGAL support: disabled
-Documentation Generation-
Xsltproc:
Xsl style sheets:
Dblatex:
Convert:
Mathml2.dtd: http://www.w3.org/Math/DTD/mathml2/mathml2.dtd
# compiling
[root@Darren2 postgis-2.1.8] # make
.
PostGIS was built successfully. Ready to install.
[root@Darren2 postgis-2.1.8] # make install
.
Make [2]: Leaving directory `/ home/tools/postgis-2.1.8/extensions/postgis_topology'
Make [1]: Leaving directory `/ home/tools/postgis-2.1.8/extensions'
Wait for about 1min
Check whether PostGIS is installed successfully
Darren2:postgres:/usr/local/pgsql: > psql
Postgres=# select * from pg_available_extensions where name like 'postgis%'
Name | default_version | installed_version | comment
-+-
Postgis | 2.1.8 | | PostGIS geometry, geography, and raster spatial types and functions
Postgis_tiger_geocoder | 2.1.8 | | PostGIS tiger geocoder and reverse geocoder
Postgis_topology | 2.1.8 | | PostGIS topology spatial types and functions
Postgres=# create extension postgis
Postgres=# create extension postgis_topology
Postgres=# create extension fuzzystrmatch
Postgres=# create extension postgis_tiger_geocoder
Postgres=#\ dx
List of installed extensions
Name | Version | Schema | Description
-+-
Fuzzystrmatch | 1.1 | public | determine similarities and distance between strings
Plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
Postgis | 2.1.8 | public | PostGIS geometry, geography, and raster spatial types and functions
Postgis_tiger_geocoder | 2.1.8 | tiger | PostGIS tiger geocoder and reverse geocoder
Postgis_topology | 2.1.8 | topology | PostGIS topology spatial types and functions
Error
(1)
[root@Darren2 postgis-2.1.8] # / configure-- with-pgconfig=/usr/local/pgsql/bin/pg_config-- with-geosconfig=/opt/geos-3.4.2/bin/geos-config-- with-projdir=/opt/proj-4.8.0/-- without-sfcgal
.
Checking for xml2-config... No
Configure: error: could not find xml2-config from libxml2 within the current path. You may need to try re-running configure with a-- with-xml2config parameter.
Solution:
Check to see if the xml2-config file exists, but the result does not exist.
[root@Darren2 postgis-2.1.8] # find /-name "xml2-config"
Check to see if libxml2 and libxml2-devel are installed
[root@Darren2 postgis-2.1.8] # rpm-qa | grep libxml2
Libxml2-2.7.6-14.el6.x86_64
Libxml2-python-2.7.6-14.el6.x86_64
Install libxml2-devel:
[root@Darren2 postgis-2.1.8] # yum install libxml2-devel-y
[root@Darren2 postgis-2.1.8] # rpm-qa | grep libxml2
Libxml2-2.7.6-21.el6_8.1.x86_64
Libxml2-python-2.7.6-21.el6_8.1.x86_64
Libxml2-devel-2.7.6-21.el6_8.1.x86_64
You can see that there is already a xml2-config file at this time
[root@Darren2 postgis-2.1.8] # find /-name "xml2-config"
/ usr/bin/xml2-config
Finally, the above compilation command can be executed successfully.
(2) error in creating extension Times
Postgres=# create extension postgis
ERROR: could not load library "/ usr/local/pgsql/lib/rtpostgis-2.1.so": libgdal.so.20: cannot open shared object file: No such file or directory
[root@Darren2 postgis-2.1.8] # ls-ltr / usr/local/pgsql/lib/rtpostgis-2.1.so
-rwxr-xr-x. 1 root root 1435637 Jul 12 05:44 / usr/local/pgsql/lib/rtpostgis-2.1.so
[root@Darren2 postgis-2.1.8] # ls-ltr / usr/local/pgsql/lib/libgdal.so.20
Ls: cannot access / usr/local/pgsql/lib/libgdal.so.20: No such file or directory
[root@Darren2 postgis-2.1.8] # find /-name 'libgdal.so.20'
/ usr/local/lib/libgdal.so.20
/ home/tools/gdal-2.0.1/.libs/libgdal.so.20
[root@Darren2 postgis-2.1.8] # cp / usr/local/lib/libgdal.so.20 / usr/local/pgsql/lib/