CentOS 7 安裝PostGIS
安裝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
修改設定檔
尋找pg_hba.conf檔案並修改
[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
將對應位置改成紅框內對應值
尋找postgresql.conf
[root@localhost ~]# find / -name postgresql.conffind / -name postgresql.conf[root@localhost ~]# vi /var/lib/pgsql/9.4/data/postgresql.conf
將監聽的ip改為’*’,取消之前的#注釋,注意要取消注釋。
修改環境變數
找到安裝主目錄
[root@localhost ~]# find / -name pgsql-9.4/usr/pgsql-9.4
設定環境變數
[root@localhost ~]# vi /etc/profile
重新啟用profile檔案,對更改生效。
source /etc/profile
關閉防火牆
systemctl stop firewalld.servicesystemctl disable firewalld.service
服務啟動
pg_ctl restart #初始化啟動了一次,所以是restart
賬戶登入
[root@localhost ~]# useradd postgres #新增postgres賬戶,已有的話,跳過本句,直接執行下一句設定密碼[root@localhost ~]# password 123456#切換到postgres賬戶[root@localhost ~]# su - postgresLast login: Mon Aug 10 10:45:32 CST 2015 on pts/0#執行psql語句-bash-4.2$ psqlpsql (9.4.4)Type "help" for help. postgres=# #這裡輸入psql命令
關於postgresql安裝,其他系統參考這裡
安裝Postgis
安裝postgis
yum install postgis2_94
如果出現以下情況
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)
請先安裝以下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
然後重新安裝postgis
yum install postgis2_94
關於postgis其他版本安裝,請參考這裡
安裝pgrouting
yum install pgrouting_94
關於pgrouting的使用,請參考這裡