Install Postgis on CentOS

pg

  1. Sources
  2. Install packages
  3. Installing osm2psql
  4. Issues
  5. Initialize PGDATA
  6. Autostart
  7. Manual Start
  8. Test Install
  9. Configure

A few instructions on how to install PostGIS on CentOS 7

Sources

Install packages

sudo yum install postgresql10-server
sudo yum install postgresql10-contri
sudo yum install bc htop atop screen
sudo yum install postgis25_10
sudo yum install postgis25_10-client

Installing osm2psql

sudo yum install osm2pgsql 

This failed due to conflict with geos … so build from source github instead.

sudo yum install git
git clone git://github.com/openstreetmap/osm2pgsql.git
sudo yum install cmake make gcc-c++ boost-devel expat-devel zlib-devel bzip2-devel postgresql-devel proj-devel proj-epsg lua-devel
cd osm2pgsql
mkdir build && cd build
cmake ..
make
sudo make install

Issues

ERROR:  could not load library "/usr/pgsql-10/lib/postgis-2.5.so": /usr/pgsql-10/lib/postgis-2.5.so: undefined symbol: GEOSFrechetDistanceDensify

In my case ‘yum remove geos36’ solved it.

Initialize PGDATA

sudo /usr/pgsql-10/bin/postgresql-10-setup initdb

Autostart

sudo systemctl enable postgresql-10.service

Manual Start

service postgresql-10 start

Test Install

sudo -u postgres psql

Configure

On centos,

  • postgresql.conf lives at /var/lib/pgsql/10/data/postgresql.conf
  • pg_hba.conf lives at pg_hba.conf/var/lib/pgsql/10/data/pg_hba.conf