How to install PostgreSQL and PostGIS using yum on CentOS7

How to install PostgreSQL and PostGIS using yum on CentOS7

1. Update the yum source

The PostgreSQL version of the default yum repository of CentOS7 is too old and is not suitable for use in this version. Find the RPM source suitable for CentOS7 at https://yum.postgresql.org/repopackages.php, copy its URL address, and install it using yum.

At the same time, install epel (Extra Packages for Enterprise Linux 7). For stability, the default yum source of CentOS7 lacks many components, which can be found on epel.

Order:

yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum -y install epel-release

2. Install PostgreSQL

Use the yum search postgre command to see multiple versions of PostgreSQL. Here I choose PostgreSQL10.
yum install -y postgresql10-server postgresql10-contrib
Initialize /usr/pgsql-10/bin/postgresql10-setup initdb
Set boot startup systemctl enable postgresql-10
Start the database systemctl start postgresql-10

3. Configure the database

  • Configure remote access, edit /var/lib/pgsql/10/data/postgresql.conf, find listen_addresses, if you want to open to all IPs, change the value of listen_addresses to '*', if you want to open to only some IPs, separate multiple IPs with , (comma plus space).
  • Configure account access permissions, edit /var/lib/pgsql/10/data/pg_hba.conf. The file is divided into 5 columns: TYPE, DATABASE, USER, ADDRESS, and METHOD. You can set different database access permissions for users with different IP addresses. The analysis of the last column METHOD is as follows:
  • trust Any connection is allowed, no password is required
  • reject rejects requests that meet the conditions (the previous conditions)
  • MD5 Receive an MD5 encrypted password
  • Password Receive a password to log in. Only use this method on trusted networks
  • gss uses gssapi authentication, only available in tcp/ip connection
  • sspi is only available in Windows
  • krb5 is not commonly used and is only available in TCP/IP
  • ident uses the operating system user name to authenticate and verify that it matches the requested database user name
  • ldap uses LDAP server authentication
  • cert uses ssl client authentication
  • pam Use the operating system's pam module service

If all IP addresses are required to log in using a password, configure it as host all all 0.0.0.0/0 md5.

4. Install PostGIS

Use the yum search postgis command to see multiple versions of PostGIS. Here I choose postgis25, yum install -y postgis25_10. After the installation is complete, switch to the postgres user and enable the extension.

// Enable plugin# su postgres 
# psql 
// Enable the pgsql plugin postgres=# create extension postgis; 
postgres=# create extension postgis_topology; 
postgres=# create extension fuzzystrmatch; 
postgres=# create extension address_standardizer; 
postgres=# create extension address_standardizer_data_us; 
postgres=# create extension postgis_tiger_geocoder;

At this point, PostgreSQL and PostGIS are installed.

Summarize

The above is what I introduced to you about how to install PostgreSQL and PostGIS on CentOS7 using yum. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time!

You may also be interested in:
  • How to run postgreSQL with docker
  • PostgreSQL Basics: A Practical Guide to SQL Operators
  • Django settings Postgresql operations
  • Python operation PostgreSQL database example [connection, addition, deletion, modification, query, etc.]
  • Example code for resetting PostgreSQL password on Mac
  • How to get the current date and time in PostgreSQL and precautions
  • Detailed explanation of the process of connecting Python to PostgreSQL database
  • PostgreSQL COALESCE usage code analysis

<<:  How to limit the value range of object keys in TypeScript

>>:  Quickly master how to get started with Vuex state management in Vue3.0

Recommend

Detailed installation and use of virtuoso database under Linux system

I've been researching some things about linke...

iFrame is a great way to use it as a popup layer to cover the background

I have been working on a project recently - Budou ...

Detailed explanation of MySQL multi-table join query

Table of contents Multi-table join query Inner Jo...

iframe parameters with instructions and examples

<iframe src=”test.jsp” width=”100″ height=”50″...

Vue uses el-table to dynamically merge columns and rows

This article example shares the specific code of ...

Docker installation of Nginx problems and error analysis

question: The following error occurred when insta...

How to upgrade CentOS7 to CentOS8 (detailed steps)

This article uses a specific example to introduce...

Linux kernel device driver virtual file system notes

/******************** * Virtual File System VFS *...

Linux parted disk partition implementation steps analysis

Compared with fdisk, parted is less used and is m...

HTML table markup tutorial (22): row border color attribute BORDERCOLORLIGHT

Within rows, light border colors can be defined i...

React implementation example using Amap (react-amap)

The PC version of React was refactored to use Ama...

Vue implements a small weather forecast application

This is a website I imitated when I was self-stud...

Detailed explanation of anonymous slots and named slots in Vue

Table of contents 1. Anonymous slots 2. Named slo...

A detailed introduction to the CSS naming specification BEM from QQtabBar

BEM from QQtabBar First of all, what does BEM mea...