Install PostGIS in CentOS 7
Install Postgresql 9.4
yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpmyum install postgresql94-server postgresql94-contribservice postgresql-9.4 initdbchkconfig postgresql-9.4 on
Modify configuration file
Find and modify the pg_cmd.conf File
[root@localhost ~]# find / -name pg_hba.conf /var/lib/pgsql/9.4/data/pg_hba.conf [root@localhost ~]# vi /var/lib/pgsql/9.4/data/pg_hba.conf
Change the corresponding position to the value in the red box.
Find postgresql. conf
[root@localhost ~]# find / -name postgresql.conffind / -name postgresql.conf[root@localhost ~]# vi /var/lib/pgsql/9.4/data/postgresql.conf
Change the ip address of the listener to '*'. Cancel the # comment. Note that you must cancel the comment.
Modify Environment Variables
Find the installation home directory
[root@localhost ~]# find / -name pgsql-9.4/usr/pgsql-9.4
Set Environment Variables
[root@localhost ~]# vi /etc/profile
Re-enable the profile file to take effect for the change.
source /etc/profile
Disable Firewall
systemctl stop firewalld.servicesystemctl disable firewalld.service
Service Startup
Pg_ctl restart # The Initialization is started once, so it is restart
Account Logon
[Root @ localhost ~] # Useradd postgres # Add an postgres account. If the account already exists, skip this sentence and directly execute the next sentence to set the password [root @ localhost ~] # Password 123456 # Switch to the S s account [root @ localhost ~] # Su-shortslast login: Mon Aug 10 10:45:32 CST 2015 on pts/0 # Run the psql statement-bash-4.2 $ psqlpsql (9.4.4) Type "help" for help. postgres ### enter the psql command here
For more information about postgresql installation, see here.
Install Postgis
Install postgis
yum install postgis2_94
If the following conditions occur:
Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libcfitsio.so.0()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libspatialite.so.2()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libnetcdf.so.6()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libfreexl.so.1()(64bit)Error: Package: postgis2_93-client-2.1.1-1.rhel6.x86_64 (pgdg93) Requires: libjson.so.0()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libarmadillo.so.3()(64bit)Error: Package: postgis2_93-2.1.1-1.rhel6.x86_64 (pgdg93) Requires: hdf5Error: Package: postgis2_93-2.1.1-1.rhel6.x86_64 (pgdg93) Requires: json-cError: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libhdf5.so.6()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libdap.so.11()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libCharLS.so.1()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libdapserver.so.7()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libdapclient.so.3()(64bit)Error: Package: postgis2_93-2.1.1-1.rhel6.x86_64 (pgdg93) Requires: libjson.so.0()(64bit)Error: Package: gdal-libs-1.9.2-4.el6.x86_64 (pgdg93) Requires: libgta.so.0()(64bit)
Install the following rpm
#CentOS 7, RHEL 7 64-bit:sudo http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm# CentOS 6, RHEL 6 64-bit:sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm# CentOS 6, RHEL 6 32-bit:sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm# CentOS 5, RHEL 5 64-bit:sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm# CentOS 5, RHEL 5 32-bit:sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Then reinstall postgis
yum install postgis2_94
For more information about how to install postgis in other versions, see here
Install pgrouting
yum install pgrouting_94
For usage of pgrouting, refer to here