If you already have a working PostgreSQL 9.5 install, and just want to skip to relevant sections, follow this list:
As a general note, these instructions are what I did for CentOS 7. For lower versions ther are some differences in packages you'll get. For example currently if you are installing on CentOS 6 (and I presume by extension other 6 family), you won't get SFCGAL and might have pgRouting 2.0 (instead of 2.1)
The list of latest PostgreSQL versions and repos for Fedora 20-22, Red Hat 5-7, CentOS 6-7, Oracle EL Linux 6-7, and Scientific Linux 5-7, Amazon Linux AMI are located at http://yum.postgresql.org/repopackages.php.
First run
uname -a
Linux centos7 3.10.0-327.4.4.el7.x86_64 #1 SMP Tue Jan 5 16:07:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
so I know its a 64-bit because of the X86_64 at the end. cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
On my CentOS 7 ran:
sudo rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
sudo yum list | grep pgdg95
should give you entries that look something like below and the ones we want are marked with pgdg95.
CGAL.x86_64 4.7-1.rhel7 pgdg95 CGAL-debuginfo.x86_64 4.7-1.rhel7 pgdg95 CGAL-demos-source.x86_64 4.7-1.rhel7 pgdg95 CGAL-devel.x86_64 4.7-1.rhel7 pgdg95 SFCGAL.x86_64 1.2.2-1.rhel7 pgdg95 SFCGAL-debuginfo.x86_64 1.2.2-1.rhel7 pgdg95 SFCGAL-devel.x86_64 1.2.2-1.rhel7 pgdg95 SFCGAL-libs.x86_64 1.2.2-1.rhel7 pgdg95 barman.noarch 1.5.1-1.rhel7 pgdg95 boxinfo.noarch 1.4.0-1.rhel7 pgdg95 check_postgres.noarch 2.22.0-1.rhel7 pgdg95 cstore_fdw_95.x86_64 1.4-1.rhel7 pgdg95 cstore_fdw_95-debuginfo.x86_64 1.4-1.rhel7 pgdg95 cyanaudit95.noarch 0.9.5-1.rhel7 pgdg95 dbi-link.noarch 2.0.0-3.rhel7 pgdg95 emaj.x86_64 1.2.0-1.rhel7 pgdg95 emaj-debuginfo.x86_64 1.1.0-1.rhel7 pgdg95 gdal.x86_64 1.11.0-4.rhel7 pgdg95 gdal-debuginfo.x86_64 1.11.0-4.rhel7 pgdg95 gdal-devel.x86_64 1.11.0-4.rhel7 pgdg95 gdal-doc.noarch 1.11.0-4.rhel7 pgdg95 gdal-java.x86_64 1.11.0-4.rhel7 pgdg95 gdal-javadoc.noarch 1.11.0-4.rhel7 pgdg95 gdal-libs.x86_64 1.11.0-4.rhel7 pgdg95 gdal-perl.x86_64 1.11.0-4.rhel7 pgdg95 gdal-python.x86_64 1.11.0-4.rhel7 pgdg95 geoip95.noarch 0.2.4-1.rhel7 pgdg95 geos.x86_64 3.5.0-1.rhel7 pgdg95 geos-debuginfo.x86_64 3.5.0-1.rhel7 pgdg95 geos-devel.x86_64 3.5.0-1.rhel7 pgdg95 geos-python.x86_64 3.5.0-1.rhel7 pgdg95 ip4r95.x86_64 2.0.2-2.rhel7 pgdg95 ip4r95-debuginfo.x86_64 2.0.2-2.rhel7 pgdg95 libevent.x86_64 2.0.22-1.rhel7 pgdg95 libevent-debuginfo.x86_64 2.0.22-1.rhel7 pgdg95 libevent-devel.x86_64 2.0.22-1.rhel7 pgdg95 libevent-doc.noarch 2.0.22-1.rhel7 pgdg95 libpqxx.x86_64 1:4.0.1-0.1.rhel7 pgdg95 libpqxx-debuginfo.x86_64 1:4.0.1-0.1.rhel7 pgdg95 libpqxx-devel.x86_64 1:4.0.1-0.1.rhel7 pgdg95 mailchimp_fdw95.x86_64 0.3.1-1.rhel7 pgdg95 multicorn95.x86_64 1.3.1-1.rhel7 pgdg95 multicorn95-debuginfo.x86_64 1.3.1-1.rhel7 pgdg95 nagios-plugins-pgactivity.noarch 1.25beta1-1 pgdg95 ogr_fdw95.x86_64 1.0.1-1.rhel7 pgdg95 ogr_fdw95-debuginfo.x86_64 1.0.1-1.rhel7 pgdg95 ora2pg.noarch 16.2-1.rhel7 pgdg95 orafce95.x86_64 3.1.2-1.rhel7 pgdg95 orafce95-debuginfo.x86_64 3.1.2-1.rhel7 pgdg95 pagila95.noarch 0.10.1-1.rhel7 pgdg95 pg_activity.noarch 1.2.0-1.rhel7 pgdg95 pg_catcheck95.x86_64 1.0.0-1.rhel7 pgdg95 pg_catcheck95-debuginfo.x86_64 1.0.0-1.rhel7 pgdg95 pg_partman95.x86_64 2.2.2-1.rhel7 pgdg95 pg_partman95-debuginfo.x86_64 2.2.2-1.rhel7 pgdg95 pg_qualstats95.x86_64 0.0.7-1.rhel7 pgdg95 pg_qualstats95-debuginfo.x86_64 0.0.7-1.rhel7 pgdg95 pg_repack95.x86_64 1.3.2-1.rhel7 pgdg95 pg_repack95-debuginfo.x86_64 1.3.2-1.rhel7 pgdg95 pg_stat_kcache95.x86_64 2.0.2-1.rhel6 pgdg95 pg_stat_kcache95-debuginfo.x86_64 2.0.2-1.rhel6 pgdg95 pg_top95.x86_64 3.7.0-3.rhel7 pgdg95 pg_top95-debuginfo.x86_64 3.7.0-3.rhel7 pgdg95 pg_track_settings95.x86_64 1.0.0-2.rhel7 pgdg95 pgadmin3_95.x86_64 1.22.0-1.rhel7 pgdg95 pgadmin3_95-debuginfo.x86_64 1.22.0-1.rhel7 pgdg95 pgadmin3_95-docs.x86_64 1.22.0-1.rhel7 pgdg95 pgagent_95.x86_64 3.4.0-2.rhel7 pgdg95 pgagent_95-debuginfo.x86_64 3.4.0-2.rhel7 pgdg95 pgbackman.noarch 1.1.0-1.rhel7 pgdg95 pgbadger.noarch 7.3-1.rhel7 pgdg95 pgbouncer.x86_64 1.7-1.rhel7 pgdg95 pgbouncer-debuginfo.x86_64 1.7-1.rhel7 pgdg95 pgbson95.x86_64 1.0.1-1.rhel7 pgdg95 pgbson95-debuginfo.x86_64 1.0.1-1.rhel7 pgdg95 pgcenter.x86_64 0.2.0-1.rhel7 pgdg95 pgcenter-debuginfo.x86_64 0.2.0-1.rhel7 pgdg95 pgcluu.noarch 2.4-1.rhel7 pgdg95 pgdg-oraclelinux95.noarch 9.5-2 pgdg95 pgdg-redhat95.noarch 9.5-2 pgdg95 pgdg-sl95.noarch 9.5-2 pgdg95 pgfincore95.x86_64 1.1.2-2.rhel7 pgdg95 pgfincore95-debuginfo.x86_64 1.1.2-2.rhel7 pgdg95 pgmemcache-95.x86_64 2.1.2-1.rhel7 pgdg95 pgmemcache-95-debuginfo.x86_64 2.1.2-1.rhel7 pgdg95 pgmp95.x86_64 1.0.2-1.rhel7 pgdg95 pgmp95-debuginfo.x86_64 1.0.2-1.rhel7 pgdg95 pgpool-II-95.x86_64 3.4.3-3.rhel7 pgdg95 pgpool-II-95-debuginfo.x86_64 3.4.3-3.rhel7 pgdg95 pgpool-II-95-devel.x86_64 3.4.3-3.rhel7 pgdg95 pgpool-II-95-extensions.x86_64 3.4.3-3.rhel7 pgdg95 pgpoolAdmin.noarch 3.4.1-1.rhel7 pgdg95 pgreplay.x86_64 1.2.0-1.rhel7 pgdg95 pgreplay-debuginfo.x86_64 1.2.0-1.rhel7 pgdg95 pgrouting_95.x86_64 2.1.0-1.rhel7 pgdg95 pgrouting_95-debuginfo.x86_64 2.1.0-1.rhel7 pgdg95 pgsi.noarch 1.2.0-1.rhel7 pgdg95 pgsphere95.x86_64 1.1.1-4.rhel7 pgdg95 pgsphere95-debuginfo.x86_64 1.1.1-4.rhel7 pgdg95 pgtap95.noarch 0.95.0-1.rhel7 pgdg95 pguri95.x86_64 1.20150415-1.rhel7 pgdg95 pguri95-debuginfo.x86_64 1.20150415-1.rhel7 pgdg95 pgxnclient.x86_64 1.2.1-1.rhel7 pgdg95 pgxnclient-debuginfo.x86_64 1.2.1-1.rhel7 pgdg95 phpPgAdmin.noarch 5.1-2.rhel7 pgdg95 plpgsql_check_95.x86_64 1.0.2-1.rhel7 pgdg95 plpgsql_check_95-debuginfo.x86_64 1.0.2-1.rhel7 pgdg95 plproxy95.x86_64 2.6-1.rhel7 pgdg95 plproxy95-debuginfo.x86_64 2.6-1.rhel7 pgdg95 plr95.x86_64 8.3.0.16-1.rhel7 pgdg95 plr95-debuginfo.x86_64 8.3.0.16-1.rhel7 pgdg95 plsh95.x86_64 1.20130823-1.rhel7 pgdg95 plsh95-debuginfo.x86_64 1.20130823-1.rhel7 pgdg95 plv8_95.x86_64 1.4.4-1.rhel7 pgdg95 plv8_95-debuginfo.x86_64 1.4.4-1.rhel7 pgdg95 postcode_95.x86_64 1.3.0-1.rhel7 pgdg95 postcode_95-debuginfo.x86_64 1.3.0-1.rhel7 pgdg95 postgis2_95.x86_64 2.2.1-3.rhel7 pgdg95 postgis2_95-client.x86_64 2.2.1-3.rhel7 pgdg95 postgis2_95-debuginfo.x86_64 2.2.1-3.rhel7 pgdg95 postgis2_95-devel.x86_64 2.2.1-3.rhel7 pgdg95 postgis2_95-docs.x86_64 2.2.1-3.rhel7 pgdg95 postgis2_95-utils.x86_64 2.2.1-3.rhel7 pgdg95 postgresql94-jdbc.noarch 9.4.1207-1.rhel7 pgdg95 postgresql94-jdbc-javadoc.noarch 9.4.1207-1.rhel7 pgdg95 postgresql95.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-contrib.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-debuginfo.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-devel.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-docs.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-libs.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-odbc.x86_64 09.05.0100-1PGDG.rhel7 pgdg95 postgresql95-odbc-debuginfo.x86_64 09.03.0400-1PGDG.rhel7 pgdg95 postgresql95-plperl.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-plpython.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-pltcl.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-python.x86_64 4.1.1-2PGDG.rhel7 pgdg95 postgresql95-python-debuginfo.x86_64 4.1.1-2PGDG.rhel7 pgdg95 postgresql95-server.x86_64 9.5.0-2PGDG.rhel7 pgdg95 postgresql95-tcl.x86_64 2.0.0-1.rhel7 pgdg95 postgresql95-tcl-debuginfo.x86_64 2.0.0-1.rhel7 pgdg95 postgresql95-test.x86_64 9.5.0-2PGDG.rhel7 pgdg95 proj.x86_64 4.8.0-2.rhel7 pgdg95 proj-debuginfo.x86_64 4.8.0-2.rhel7 pgdg95 proj-devel.x86_64 4.8.0-2.rhel7 pgdg95 proj-epsg.x86_64 4.8.0-2.rhel7 pgdg95 proj-nad.x86_64 4.8.0-2.rhel7 pgdg95 python-argcomplete.noarch 0.3.7-1.rhel7 pgdg95 python-argh.noarch 0.23.0-1.rhel7 pgdg95 python-psycopg2.x86_64 2.6.1-1.rhel7 pgdg95 python-psycopg2-debuginfo.x86_64 2.6.1-1.rhel7 pgdg95 python-psycopg2-doc.x86_64 2.6.1-1.rhel7 pgdg95 repmgr95.x86_64 3.0.3-1.rhel7 pgdg95 repmgr95-debuginfo.x86_64 3.0.3-1.rhel7 pgdg95 slony1-95.x86_64 2.2.4-4.rhel7 pgdg95 slony1-95-debuginfo.x86_64 2.2.4-4.rhel7 pgdg95 split_postgres_dump.noarch 1.3.3-1.rhel7 pgdg95 tail_n_mail.noarch 1.27.0-1.rhel7 pgdg95 tds_fdw95.x86_64 1.0.7-1.rhel7 pgdg95 tds_fdw95-debuginfo.x86_64 1.0.7-1.rhel7 pgdg95 usda-r18.noarch 1.0-2.rhel7 pgdg95
We usually install the below. The devel is optional but needed if you want to compile some other add-on later like non-packaged extensions.
yum install postgresql95 postgresql95-server postgresql95-libs postgresql95-contrib postgresql95-devel
Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgresql95 x86_64 9.5.0-2PGDG.rhel7 pgdg95 1.3 M postgresql95-contrib x86_64 9.5.0-2PGDG.rhel7 pgdg95 526 k postgresql95-devel x86_64 9.5.0-2PGDG.rhel7 pgdg95 1.7 M postgresql95-libs x86_64 9.5.0-2PGDG.rhel7 pgdg95 213 k postgresql95-server x86_64 9.5.0-2PGDG.rhel7 pgdg95 4.1 M Installing for dependencies: libxslt x86_64 1.1.28-5.el7 base 242 k Transaction Summary ================================================================================ Install 5 Packages (+1 Dependent package) Total download size: 8.1 M Installed size: 34 M Is this ok [y/d/N]:
It should then download the packages and install them with a Complete! exclamation when done.
If you plan to run multiple versions of PostgreSQL e.g. stable 9.5 and devl 9.6, on the same server (so they use different ports), or you just need to be in control of all your options, you'll want to tweak your services scripts a bit. The best way to do that is to edit/create a file in /etc/sysconfig/pgsql/postgresql-9.5 with your preferred changes:
Note that # are remarks to you so don't type them in
su root vi /etc/sysconfig/pgsql/postgresql-9.5
if the file doesn't exist -- it will be blank which is okay: Click i to insert a line and start typing. I generally like to run on non-standard ports just to avoid postgresql bots blindly pinging on 5432. You also need to run on different ports if you have multiple instances running on same server. So to change you can: Note: PGDATA you don't need to add unless you are unhappy with the default location.
My file when I am done will look something like this
PGPORT=5440 PGDATA=/pgdata95
Click Escape key followed by :w :q (:w saves the file and :q exits)
New versions you can once connected to system
With the Yum setup each version of postgresql goes in its own separate folder, so you can easily have parallel installs of different versions of PostgreSQL without worring about overriding the default data folder.
I'll reiterate the key elements and consequences of these changes you need to watch out for.
Installing postgres creates a user account called postgres. If you want to change the password to something you know do this:
sudo passwd postgres
You'll be prompted for a new password.
If you want the service to start up on reboot, then simply do this:
su root service postgresql-9.5 initdb
If you get an error:
Do
/usr/pgsql-9.5/bin/postgresql95-setup initdb
service postgresql-9.5 start chkconfig --list #(to see list of services) chkconfig postgresql-9.5 on #(to have start on bootup)
For newer CentOS like 7+, use
systemctl list-unit-files #(to see list of services)
The data cluster is created by default in /var/lib/pgsql/9.5/data and the extensions folder is in /usr/pgsql-9.5/share/extension/ and the binaries
are in /usr/pgsql-9.5/bin. To use psql, you can generally get away with just typing psql
without the full path, but if you have multiple installations of PostgreSQL, you're better off being explicit which one you want.
For the rest of these exercises, we are going to assume you are just using the default ports etc.
To install the adminpack useful for viewing logs and editing postgresql.conf from the comfort of PgAdmin, don't forget to install the admin pack
su postgres cd ~/ /usr/pgsql-9.5/bin/psql -p 5432 -c "CREATE EXTENSION adminpack;"
PostGIS unfortunately has a lot of dependencies because of GDAL and JSON dependency introduced in 2.0 and while some of the time it's as easy as adding:
If still under postgres switch back to root with exit.
sudo yum install postgis2_95 postgis2_95-client
The postgis2_95-client contains the PostGIS commandline tools shp2gpsql, pgsql2shp, raster2pgsql that are useful for loading or exporting spatial data.
It often is not. As with this virgin box we tried installing on we got these errors:
: --> Finished Dependency Resolution Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libdapclient.so.3()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libdap.so.11()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libspatialite.so.2()(64bit) Error: Package: postgis2_95-2.2.0-1.rhel6.x86_64 (pgdg95) Requires: hdf5 Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libarmadillo.so.4()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libCharLS.so.1()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libgta.so.0()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libgeotiff.so.1.2()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libfreexl.so.1()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libdapserver.so.7()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libcfitsio.so.0()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libnetcdf.so.6()(64bit) Error: Package: gdal-libs-1.9.2-7.rhel6.x86_64 (pgdg95) Requires: libhdf5.so.6()(64bit)
The issue is the dependency packages are not distributed with yum postgresql repo. Most of these are in the RHEL Extra Packages for Enterprise Linux (EPEL) repo. So if you get these errors, do the following:
The master mirror are located at http://dl.fedoraproject.org/pub/epel.
First try:
yum -y install epel-release
If that doesn't work, you might have to find the explicit epel repo
For CentOS 6, RHEL 6 64-bit/32-bit (you may need to find the version with
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
For CentOS 5, RHEL 5 64-bit use:
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
Since we are on CentOS 6 64-bit we went with the second set.
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
You should get a screen that looks something like this if successful
.. .. Preparing... ########################################### [100%] 1:epel-release ########################################### [100%]
Now we repeat the above command again:
sudo yum install postgis2_95
After the above, you should see a screen that looks like this:
Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgis2_95 x86_64 2.2.1-3.rhel7 pgdg95 3.8 M Installing for dependencies: CGAL x86_64 4.7-1.rhel7 pgdg95 253 k CharLS x86_64 1.0-5.el7 epel 63 k SFCGAL x86_64 1.2.2-1.rhel7 pgdg95 14 k SFCGAL-libs x86_64 1.2.2-1.rhel7 pgdg95 1.7 M armadillo x86_64 4.320.0-1.el7 epel 21 k arpack x86_64 3.1.3-2.el7 epel 101 k atlas x86_64 3.10.1-10.el7 base 4.5 M blas x86_64 3.4.2-5.el7 base 399 k boost-date-time x86_64 1.53.0-25.el7 base 51 k boost-serialization x86_64 1.53.0-25.el7 base 170 k boost-system x86_64 1.53.0-25.el7 base 39 k boost-thread x86_64 1.53.0-25.el7 base 57 k cfitsio x86_64 3.370-1.el7 epel 526 k fontconfig x86_64 2.10.95-7.el7 base 228 k fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k freexl x86_64 1.0.0f-1.el7 epel 31 k gdal-libs x86_64 1.11.2-2.el7 epel 4.4 M geos x86_64 3.5.0-1.rhel7 pgdg95 540 k giflib x86_64 4.1.6-9.el7 base 40 k hdf5 x86_64 1.8.12-7.el7 epel 1.6 M jasper-libs x86_64 1.900.1-29.el7 base 149 k jbigkit-libs x86_64 2.0-11.el7 base 46 k lapack x86_64 3.4.2-5.el7 base 5.4 M lcms2 x86_64 2.6-2.el7 base 150 k libICE x86_64 1.0.9-2.el7 base 65 k libSM x86_64 1.2.2-2.el7 base 39 k libX11 x86_64 1.6.3-2.el7 base 605 k libX11-common noarch 1.6.3-2.el7 base 162 k libXau x86_64 1.0.8-2.1.el7 base 29 k libXdamage x86_64 1.1.4-4.1.el7 base 20 k libXext x86_64 1.3.3-3.el7 base 39 k libXfixes x86_64 5.0.1-2.1.el7 base 18 k libXxf86vm x86_64 1.1.3-2.1.el7 base 17 k libdap x86_64 3.13.1-2.el7 epel 423 k libgeotiff x86_64 1.2.5-14.el7 epel 545 k libgfortran x86_64 4.8.5-4.el7 base 293 k libgta x86_64 1.0.4-1.el7 epel 32 k libjpeg-turbo x86_64 1.2.90-5.el7 base 134 k libpng x86_64 2:1.5.13-7.el7_2 updates 213 k libquadmath x86_64 4.8.5-4.el7 base 182 k libtiff x86_64 4.0.3-14.el7 base 167 k libtool-ltdl x86_64 2.4.2-20.el7 base 49 k libwebp x86_64 0.3.0-3.el7 base 170 k libxcb x86_64 1.11-4.el7 base 189 k libxshmfence x86_64 1.2-1.el7 base 7.2 k mesa-libGL x86_64 10.6.5-3.20150824.el7 base 184 k mesa-libGLU x86_64 9.0.0-4.el7 base 196 k mesa-libglapi x86_64 10.6.5-3.20150824.el7 base 39 k mpfr x86_64 3.1.1-4.el7 base 203 k netcdf x86_64 4.3.3.1-5.el7 epel 693 k ogdi x86_64 3.2.0-0.19.beta2.el7 epel 248 k openjpeg-libs x86_64 1.5.1-10.el7 base 85 k poppler x86_64 0.26.5-5.el7 base 782 k poppler-data noarch 0.4.6-3.el7 base 2.2 M proj x86_64 4.8.0-4.el7 epel 181 k unixODBC x86_64 2.3.1-11.el7 base 413 k xerces-c x86_64 3.1.1-7.el7_1 base 878 k Transaction Summary ================================================================================ Install 1 Package (+57 Dependent packages) Total download size: 33 M Installed size: 169 M Is this ok [y/d/N]:
Click y
Is this ok [y/d/N]:Type: y
After you are done you should have a screen like this:
Installed: postgis2_95.x86_64... Complete!
Note that after all this, you still need to enable PostGIS in each database you will want to use it in. Refer to Enabling Extensions for more details. The extension enabling is also pretty generic for all OS, and is described in PostGIS Install http://postgis.net/install/
ogr_fdw the spatial vector foreign data wrapper, is also available on yum. To install:
yum install ogr_fdw95
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.5ninesolutions.com * epel: mirror.us.leaseweb.net * extras: mirror.atlanticmetro.net * updates: centos.mirror.constant.com Resolving Dependencies --> Running transaction check ---> Package ogr_fdw95.x86_64 0:1.0.1-1.rhel7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: ogr_fdw95 x86_64 1.0.1-1.rhel7 pgdg95 23 k Transaction Summary ================================================================================ Install 1 Package Total download size: 23 k Installed size: 54 k Is this ok [y/d/N]:
Type y
If successful, you should see
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.5ninesolutions.com * epel: mirror.us.leaseweb.net * extras: mirror.atlanticmetro.net * updates: centos.mirror.constant.com Resolving Dependencies --> Running transaction check ---> Package ogr_fdw95.x86_64 0:1.0.1-1.rhel7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: ogr_fdw95 x86_64 1.0.1-1.rhel7 pgdg95 23 k Transaction Summary ================================================================================ Install 1 Package Total download size: 23 k Installed size: 54 k Is this ok [y/d/N]: y Downloading packages: ogr_fdw95-1.0.1-1.rhel7.x86_64.rpm | 23 kB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : ogr_fdw95-1.0.1-1.rhel7.x86_64 1/1 Verifying : ogr_fdw95-1.0.1-1.rhel7.x86_64 1/1 Installed: ogr_fdw95.x86_64 0:1.0.1-1.rhel7 Complete!
pgRouting is a PostgreSQL extension that extends PostGIS for building Location Based Services (LBS) specifically for trip navigation and resource dispatch. It is the subject of our upcoming book pgRouting: A practical guide due out later this year but will be ready for early purchase and Early Preview hopefully within the next week.
Note that since pgRouting relies on PostGIS for much of its functionality, you should have install PostGIS first before attempting to install pgRouting.
To install:
yum install pgrouting_95
You should see a screen like:
Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pgrouting_95 x86_64 2.1.0-1.rhel7 pgdg95 243 k Transaction Summary ================================================================================ Install 1 Package Total download size: 243 k Installed size: 1.1 M Is this ok [y/d/N]:
Type: y to the prompt.
You should see a screen like this
Downloading packages: pgrouting_95-2.1.0-1.rhel7.x86_64.rpm | 243 kB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pgrouting_95-2.1.0-1.rhel7.x86_64 1/1 Verifying : pgrouting_95-2.1.0-1.rhel7.x86_64 1/1 Installed: pgrouting_95.x86_64 0:2.1.0-1.rhel7 Complete!
Now refer to the section Enabling Extensions for more details and also check out the pgRouting manual for pgRouting 2.1 at http://docs.pgrouting.org/2.1/doc/index.html.
To install PostGIS 2.2 and the extended family packaged with PostGIS 2.2 you'd create a database and install the extensions.
su postgres /usr/pgsql-9.5/bin/psql -p 5432 CREATE DATABASE gistest; \connect gistest;
Should give you message: You are now connected to database "gistest" as user "postgres".
Next install the extensions
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION ogr_fdw;
To verify the install do:
SELECT postgis_full_version();
You should get something like:
postgis_full_version ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.1" LIBJSON="0.11" TOPOLOGY RASTER
If the above output returns 2.2.0 instead of 2.2.1+, you should upgrade, by doing the following:
Exit out psql
\q exitand run yum with:
yum update postgis2_95
Which should give you:
Resolving Dependencies --> Running transaction check ---> Package postgis2_95.x86_64 .. will be updated ---> Package postgis2_95.x86_64 .. will be an update --> Finished Dependency Resolution :
Now connect back as postgres and upgrade your database by doing the following
su postgres /usr/pgsql-9.5/bin/psql -p 5432 -d gistest #once in psql console do the following ALTER EXTENSION postgis UPDATE; -- repeat for each extension so for example -- if you installed postgis_topology ALTER EXTENSION postgis_topology UPDATE; -- then run to check version SELECT postgis_full_version();
You should now see 2.2.1 listed
To install pgRouting and verify install
CREATE EXTENSION pgrouting;
SELECT * FROM pgr_version();
Should output
version | tag | build | hash | branch | boost ---------+-----------------+-------+---------+--------+-------- 2.1.0 | pgrouting-2.1.0 | 1 | b38118a | master | 1.53.0 (1 row)