19

When I am in my postgres db and tried to create an extension for my db, I get this error

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

I know there are so many posts out there with this error and solutions and I tried them all too. Found so much in stackoverflow but none of them worked.

I realized in my postgresql directory there are 9.2, 9.3, 9.4, 9.5, 9.6,

I went into the directory in the error and I realized there is really no postgis.control inside 9.5

I checked my psql version and showed 9.6.1

I went into 9.6 folder and I DO see a postgis.control in it.

I want to changed the installation directory so when i run

create extension postgis

it would go

"/usr/share/postgresql/9.6/extension/postgis.control"

instead of

"/usr/share/postgresql/9.5/extension/postgis.control"

Can someone please give me a hand?

Thanks in advance.

P.S. Using Ubuntu 14.04 and also have Ubuntu 16.04 as desktop which I haven't try to install postgis yet

Tsuna
  • 2,098
  • 6
  • 24
  • 46
  • 6
    The PostGIS package is specific to a Postgres version. You just need to install one for 9.5 (e.g. [`postgresql-9.5-postgis-2.3`](https://www.ubuntuupdates.org/package/postgresql/trusty-pgdg/main/base/postgresql-9.5-postgis-2.3)). – Nick Barnes Jan 16 '17 at 08:49

2 Answers2

34

You should use the following command:

sudo apt-get install postgresql-9.6-postgis-scripts
g00glen00b
  • 41,995
  • 13
  • 95
  • 133
  • 4
    on a recent ubuntu, even `sudo apt install postgis` does work - it installs all the needed libraries, that work with the installed postgres version. – benzkji Jan 16 '18 at 14:33
  • 6
    `sudo apt install postgis` - beware of such kind of installation if you don't have postgres of latest version - because that command install also latest postgres and make it default for your system. – alexche8 Feb 25 '18 at 12:48
-2

Use the following command to get the in your 9.5 version directory:

sudo apt install postgis postgresql-9.5-postgis-2.3