50

I have installed PostgreSQL 9.x and PostGIS 1.5/2.0 several times and have never had this problem.

I just got a new CentOS 6.3 server up and running and and I have Postgres 9.3 functioning as expected. I have run

yum install postgis2_93

and I can see the files in

/usr/pgsql-9.3/share/contrib/

however, when I run

CREATE EXTENSION postgis;

I receive

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

the tutorials (#1, #2) I have used don't show any steps between installing PostGIS and creating the extension.

What am I missing?

  • What you're missing is 'postgis.control' :) The question is 'why' or 'where'. First, see if you even have a copy by running 'find /usr -name postgis.control'. If you don't, then it's a packaging problem with the brand new postgis2_93 package that needs to be fixed. – Paul Ramsey Sep 12 '13 at 17:06
  • Oh, you can see the files (including 'postgis.control'?) share/contrib, but from the error message pgsql is looking in share/extension. There might have been a change in default extension location from 9.2 to 9.3 that the packager missed. – Paul Ramsey Sep 12 '13 at 17:07
  • @PaulRamsey - I ran find /usr -name postgis.control and it is not present. I can see some files in share/contrib; however, postgis.control is not among them... what do you suggest I do? wait for a fix, make my own, something else? – losthorse Sep 12 '13 at 17:42
  • @PaulRamsey - I just verified that postgis-2.1.so is present in /lib does this mean I can just make my own postgis.control file? – losthorse Sep 12 '13 at 18:00
  • If you can find a postgis.sql file, you can run that into your database (and the spatial_ref_sys.sql file) to manually spatialize your database. Report the missing control file to the packager, that's a big problem. – Paul Ramsey Sep 13 '13 at 16:42

12 Answers 12

11

If you can find a postgis.sql file, you can run that into your database (and the spatial_ref_sys.sql file) to manually spatialize your database. Report the missing control file to the packager, that's a big problem.

53

I just had the same problem on Ubuntu Server 14.04. I installed the postgis extension from the official Ubuntu repositories using apt-get install postgis.

Then, find /usr -name postgis.control didn't return any results.

The reason was extension/postgis.control wasn't installed because postgis-scripts wasn't.

$ aptitude search postgis
i   libpostgis-java                                  - Geographic objects support for PostgreSQL -- JDBC support 
i   postgis                                          - Geographic objects support for PostgreSQL                 
p   postgis:i386                                     - Geographic objects support for PostgreSQL                 
i   postgis-doc                                      - Geographic objects support for PostgreSQL -- documentation
i   postgresql-9.3-postgis-2.1                       - Geographic objects support for PostgreSQL 9.3             
p   postgresql-9.3-postgis-2.1:i386                  - Geographic objects support for PostgreSQL 9.3             
i   postgresql-9.3-postgis-2.1-scripts               - PostGIS for PostgreSQL 9.3 -- scripts -- dummy package    
i   postgresql-9.3-postgis-scripts                   - Geographic objects support for PostgreSQL 9.3 -- scripts 

The solution is to install it.

On debian-like distros:

apt-get install postgis*

The aptitude package manager will automatically determine the correct package versions to install. The postgis-doc will be installed too.

EDIT

Like some people noticed in comments, the postgis* is not required because it installs some packages not strictly required to just get it to work.

The required packages are postgis and postgresql-9.x-postgis-scripts meta packages. They select the correct real version for your system. So the commands to install the required packages are

 $ sudo apt-get install postgis postgresql-9.3-postgis-scripts

for postgresql-9.3. Ubuntu 16.04 runs postgresql-9.5 so the command becomes:

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

You can check the success of the operation by running the following command:

find /usr -name postgis.control

On my server, it now returns:

/usr/share/postgresql/9.3/extension/postgis.control

You can now enable the extension on any database on your postgres server:

  • connect to your db with superuser (postgres by default)
  • run CREATE EXTENSION postgis;

Your public schema now contains all postgis objects and functions.

  • ...wish you had Windows direction too – CodyBugstein Sep 10 '14 at 14:38
  • ...never mind! Solved it in Windows by reinstalling PostGIS via StackBuilder – CodyBugstein Sep 10 '14 at 14:48
  • 4
    Thanks this fixed my Ubuntu problem! The "postgis*" gets a bunch of stuff you don't need. I think "apt-get install postgis postgresql-9.3-postgis-2.1" is sufficient. – Nelson Dec 2 '14 at 19:15
  • You're probably right. In my case, a full install was preferable but it doesn't the rule. – Rémi B. Dec 3 '14 at 8:35
  • "apt-get install postgis*" rules. Thanks! – nemesisdesign Jun 6 '15 at 18:23
18

In Ubuntu 14.04 you also need to install the postgresql-9.3-postgis-scripts package. After I ran

sudo apt-get install postgis postgresql-9.3-postgis-scripts

I was then able to successfully run

CREATE EXTENSION postgis;

in my database to initialise PostGIS.

3

I had the same issue, I just ran the command

sudo apt-get install postgis

I was using Ubuntu 18.04

2

Another source which caused the problem could be the missing PostGIS bundle, this can be defined in install menu or in your case afterwards. Therefor, open windows start, head to PostgreSQL an start the Application Stack Builder. Then select PostgreSQL, with that possible applications are loaded. For the PostGIS bundle you just need to install the extension suitable to your operating system (32- or 64bit), simply direct to Spatial Extensions.

After all here the recommended steps:

  1. start Application Stack Builder
  2. Direct to Spatial Extensions
  3. Install PostGIS bundle

Now you can add the extension with CREATE EXTENSION postgis; in your SQL Query.

1

I encountered the same problem, I think the problem is that the package postgis2_93 is not installed in the expected place as postgresql would expect. You can try using another repo, which might give you the correct place. Or you can search to add extensions manually by specifying the place. In my case, the file is in /usr/pgsql-9.4/

1

I had my worst nightmare while installing Postgis 2.X on SLES 12 SP1. which doesnt have compatible package in zypper repo

Here is how is resolved it on my Postgres server instance running 9.4.X

Prerequsite packages which i have installed prior to PostGis based on the errors

  1. Proj 4 Download source cold, Build --> make install
  2. install Gdal andjibson by adding zypper repo zypper addrepo http://download.opensuse.org/repositories/Application:Geo/SLE_12_SP1_Backports/Application:Geo.repo
  3. zypper install gdal gdal-devel libjson-c-devel libjson

Installing Postgis

now if you goto postgress and create extension postgis; will work

Important while configuring you should specify pg-config path and geosconfig path and You SHOULD NOT include "without Raster" as RASTER plays main role in creating the postgis extension

1

For Ubuntu 16.04 run this command:

sudo apt-get install postgis postgresql-9.6-postgis-2.3-scripts

note that you should specify your version number for both postgresql (9.6 in my case) and postgis (2.3 in my case).

0

If you are using brew, uninstall PostGIS and reinstall it. This will create the extension files.

  • This didn't work for me, although I see them in brew ls --verbose postgis – dps Jun 18 at 2:45
0

On some distributions the extensions get packaged in the postgresql-contrib package. This holds certainly true on RedHat/CenOS where the extensions are in postgresql-contrib where xx is the magor and minor release numbers without the full stops (postgresql95-contrib for postgres 9.5).

0

For me, using Fedora 25 and pg 9.5, it worked when I did the following changes:

  • Install yum postgis package

    $ yum install postgis2_95

  • Download the postgis scripts .deb package

  • Extract it and copy the directories 'contrib' and 'extension' in extracted usr/share/postgresql/9.5 to the the same path in your pgsql (maybe changing permissions to).

  • Restart the server

0

In my case (Linux Mint 18.1 Serena) I had to remove posgresql-9.5 and postgis newly installed from default repository.

sudo apt remove postgis*
sudo apt remove postgresql*

And install version 9.6 from PosgreSQL repository:

sudo apt install postgresql-9.6 postgresql-9.6-postgis-2.3 postgresql-9.6-postgis-2.3-scripts postgresql-contrib-9.6

I'm not sure, version has anything to do with missing postgis.control file. But I wanted 9.6 version anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.