Hướng dẫn cài đặt PostGIS trên CentOS 7
Bước 1. Cài đặt PostgreSQL
Bước 2: Cài đặt EPEL repository cho CentOS 7
sudo yum -y install epel-release
Bước 3: Cài đặt PostGIS trên CentOS7
Cài cho PostgreSQL 12:
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install postgis25_12
Cài cho PostgreSQL 11:
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install postgis25_11
Bước 4: Kiểm tra lại cài đặt
[root@v2 ~]# rpm -qi postgis25_11
Name : postgis25_11
Version : 2.5.5
Release : 5.rhel7
Architecture: x86_64
Install Date: Sun 15 May 2022 03:28:14 PM +07
Group : Unspecified
Size : 29719583
License : GPLv2+
Signature : DSA/SHA1, Thu 15 Jul 2021 01:56:42 AM +07, Key ID 1f16d2e1442df0f8
Source RPM : postgis25_11-2.5.5-5.rhel7.src.rpm
Build Date : Thu 15 Jul 2021 01:55:52 AM +07
Build Host : koji-centos7-x86-64-pgbuild
Relocations : (not relocatable)
Vendor : PostgreSQL Global Development Group
URL : http://www.postgis.net/
Summary : Geographic Information Systems Extensions to PostgreSQL
Description :
PostGIS adds support for geographic objects to the PostgreSQL object-relational
database. In effect, PostGIS "spatially enables" the PostgreSQL server,
allowing it to be used as a backend spatial database for geographic information
systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS
follows the OpenGIS "Simple Features Specification for SQL" and has been
certified as compliant with the "Types and Functions" profile.
Bước 5: Kích hoạt PostGIS
1. Chuyển sang người dùng postgres
sudo -i -u postgres
2. Tạo test user/db
-bash-4.2$ createuser test_user
-bash-4.2$ createdb test_db -O test_user
3. Kết nối đên test_db
-bash-4.2$ psql -d test_db
psql (11.2)
Type "help" for help.
4. Kích hoạt PostGIS cho test_db
test_db=# CREATE EXTENSION postgis;
CREATE EXTENSION
5. Kiểm tra lại
test_db=# SELECT PostGIS_version();
postgis_version
2.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)
test_db=# \q