How to install Postgresql-9.6 and PostGIS-2.3 on Ubuntu 17.04 (Zesty Zapus) in six easy steps (updated 31-05-2017).

Install Ubuntu 17.04 (Zesty Zapus)


1. check your Ubuntu version:-

lsb_release -a

Install Postgresql


2. On the server or your PC (Terminal):-

sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib

Create a database and a user for access


Replace DATABASE_NAME_HERE and USER_NAME_HERE with the values you want to use.
# this will prompt you for a database password...also note the capital letter 'O' not number '0' (zero) below:-

3. sudo -u postgres createuser -P USER_NAME_HERE
sudo -u postgres createdb -O USER_NAME_HERE DATABASE_NAME_HERE

Test Connection to Postgresql


4. psql -h localhost -U USER_NAME_HERE DATABASE_NAME_HERE

Postgresql will ask you for your password. Then you should see the following:

DATABASE_NAME_HERE=>

To exit type:-

\q

To add PostGIS-2.3 support to the database


5. sudo apt-get install -y postgis postgresql-9.6-postgis-2.3
# typing 'postgresql-9.5' instead of postgresql-9.6 above will fail.

sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" DATABASE_NAME_HERE

6. Finally... install PgAdmin3 and set your 'service' connections

 sudo apt-get install pgadmin3

My thanks to Jon Saints for his original post dated from 13th August 2014 (for Ubuntu 14.04)
http://www.saintsjd.com/2014/08/13/howto-install-postgis-on-ubuntu-trusty.html
http://www.github.com/saintsjd
http://facebook.com/saintsjd

Comments

  1. I've got a problem. Postgis depends on libgdal1i but it's not installable.

    ReplyDelete
    Replies
    1. Try:

      apt-get remove libgal1i

      Then when that library is broken as you try to remove it, remove any other programs listed that are said to be broken. Then re-install piece by piece.

      Delete
  2. Hello,

    thanks a lot for this article.
    quick question; ive setup postgresql 9.6 with postgis 2.3 on an ubuntu 16 server. the exensions are all set. the problem is i keep getting this error
    around

    usr@host:~$ psql -h localhost -U usr_name db_name
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    perl: warning: Falling back to a fallback locale ("en_US.UTF-8")

    does it affect functionality? im setting postgres+postgis for testing with mapinfo and see if migrating from mysql is justifiable.

    thanks again

    ReplyDelete
    Replies
    1. command =>
      dpkg-reconfigure locales

      sorts this out

      Delete
  3. Unable to successfully run this one:
    sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" DB_NAME

    I keep getting this error:

    ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/postgis.control": No such file or directory

    ReplyDelete
    Replies
    1. You need to install the postgis related packages before running the command.

      $ sudo apt-get install postgis postgresql-9.5-postgis-2.1

      then

      $ sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" DATABASE_NAME_HERE

      Delete

Post a Comment

Popular posts from this blog

Qgis-server...Installing the QGIS Lizmap Plugin & Lizmap Web Client

Qgis-server...Installation on Ubuntu 16.04 LTS

Install QGIS 3.22 LTS with QGIS-SERVER-3.22 and Apache2 on Ubuntu 22.04 LTS