Install the postgis plugin
Prerequisite:
proj, geos, gdal must be installed before installing PostGIS
install proj
Download proj-5.0.0.tar.gz:
http://download.osgeo.org/proj/proj-5.0.0.tar.gz
upload to /opt/postgresql directory
cd /opt/postgresql
decompress
tar xf proj- 5.0.0.tar.gz
Enter the proj-5.0.0 directory and execute the check configuration command./configure
--prefix=/opt/postgresql/pginstalldir/plugin/proj
Compile
make
install
make
install After the installation is complete configure and load the dynamic link library
vi /etc/ld.so.conf.d/proj-5.0.0.conf
configure the following information
/opt/postgresql/pginstalldir/plugin/proj/lib
save and Exit
Execute the command to load configuration information:
ldconfig
install geos
Download geos-3.6.5.tar.bz2: http://download.osgeo.org/geos/geos-3.6.5.tar.bz2
Upload to /opt/postgresql directory
Compress and decompress
cd /opt/postgresql
if the system Without bz2, install bz2
download address: http://sourceware.org/bzip2/downloads.html
If there is a network, it is recommended to install yum
yum -y install bzip2
decompress
tar -jxvf geos-3.6.5.tar.bz2
compile ( Make sure the path has been created)
./configure --prefix=/opt/postgresql/pginstalldir/plugin/geos/
will report the following error
This does not affect, just make and make install directly
However, there will be gcc errors during compilation. You need to install gcc and recompile
yum -y install gcc-c++
to re-execute./configure
--prefix=/opt/postgresql/pginstalldir/plugin/geos/
(the compilation and inspection time here is longer)
Execute compilation
make
Execute installation
make install
After the installation is complete configure and load the dynamic link library
vi /etc/ld.so.conf.d/geos-3.6.5.conf
configure the following information
/opt/postgresql/pginstalldir/plugin/geos/lib
Save and exit
Execute the command to load configuration information:
ldconfig
install gdal
Download gdal-2.0.1.tar.gz: http://download.osgeo.org/gdal/2.0.1/gdal-2.0.1.tar.gz
Upload to /opt/postgresql directory
Unzip
cd /opt/postgresql
Decompression: tar xf gdal-2.0.1.tar.gz
Create a gdal directory under the /opt/postgresql/pginstalldir/plugin/ directory
Enter the gdal-2.0.1 directory and execute the check configuration command./configure
--prefix=/opt/ postgresql/pginstalldir/plugin/gdal
(it takes a long time to compile and check here)
execute compile
make
execute install
make install configure and load the dynamic link library vi /etc/ld.so.conf.d/gdal-2.0.1
after the installation is complete .
The conf
configuration is as follows:
/opt/postgresql/pginstalldir/plugin/gdal/lib
Save and exit
Execute the command to load configuration information:
ldconfig
Install protobuf
Upload the installation package to /usr/local/src
Enter the /usr/local/src directory, use the command to decompress
tar -zxvf protobuf-all-3.20.1.tar.gz
enter the decompressed directory
cd protobuf-3.20.1
to perform compilation check
./configure
compile
make
install
make install
add to the environment variable
vi /etc/profile
add the following content
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
save and exit
execute the command to make it take effect
source /etc/profile
Install protobuf-c
Upload the installation package to /usr/local/src
Enter the /usr/local/src directory, use the command to decompress
tar -zxvf protobuf-c-1.4.0.tar.gz
enter the decompressed directory
cd protobuf-c-1.4.0
to execute Compile check./configure
compile
make
install
make
install
install postgis
Download postgis-3.2.1.tar.gz:
(Note: postgis3.2 depends on proj4 at least 4.9 and above)
http://download.osgeo.org/postgis/source/postgis-3.2.1.tar.gz
upload Go to the /opt/postgresql directory to
decompress
cd /opt/postgresql
to decompress: tar xf postgis-3.2.1.tar.gz
to enter the postgis-3.2.1 directory and execute the check configuration command./configure
--prefix=/opt/postgresql/ pginstalldir/plugin/uuid
–with-pgconfig=/opt/postgresql/pginstalldir/bin/pg_config
–with-geosconfig=/opt/postgresql/pginstalldir/plugin/geos/bin/geos-config
–with-gdalconfig=/opt/postgresql /pginstalldir/plugin/gdal/bin/gdal-config
–with-projdir=/opt/postgresql/pginstalldir/plugin/proj
ERR1:Perl
Perl needs to be installed, download address:
https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz
Upload the perl-5.34.0.tar.gz package to the /usr/local/src directory
Enter /usr/local/src
tar -xzf perl-5.34.0.tar.gz
cd perl-5.34.0
./Configure -de
make
make test
make install
ERR2:libxml2
yum -y install libxml2-devel
ERR3
An error was reported by gdal, but it has been installed before.
Solution:
create the file /etc/ld.so.conf.d/postgresql-14.2.conf
/opt/postgresql/pginstalldir/lib/
Execute the complete check command again./configure
--prefix=/opt/postgresql/pginstalldir/plugin/uuid
–with-pgconfig=/opt/postgresql/pginstalldir/bin/pg_config
–with-geosconfig=/opt/postgresql/pginstalldir/ plugin/geos/bin/geos-config
–with-gdalconfig=/opt/postgresql/pginstalldir/plugin/gdal/bin/gdal-config
–with-projdir=/opt/postgresql/pginstalldir/plugin/proj
no error
make
make install
Add extensions to the database
Use the psql command to link to the database
Execute create extension postgis;
create an extension error, here is because the root used when installing postgis before,
chown -R postgres:postgres /opt/postgresql/
restart postgresql
pg_ctl restart
Execute the verification sql
SELECT ST_AsText(ST_AsMVTGeom( ST_GeomFromText('POLYGON ((0 0, 10 0, 10 5, 0 -5, 0 0))'), ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false));
to install the postgis plug-in to complete.