What to do : If sudo -u postgres psql -c "create extension postgis;" dhis2 fails

Just learned one issue and workaround during installation. Sharing it here…

If you are following the installation from the master and getting an error like below

$ sudo -u postgres psql -c “create extension postgis;” dhis2
ERROR: could not open extension control file “/usr/share/postgresql/10/extension/postgis.control”: No such file or directory

Most likely you tried to install postgresql-10-postgis-2.4 version and ubuntu installed a different package based on regex ( selecting 'postgresql-10-postgis-2.4-scripts' for regex 'postgresql-10-postgis-2.4')

Fix: Current postgis version for postgres10 is 2.5 so run the following commands

sudo apt-get install postgresql-10-postgis-2.5
$ sudo -u postgres psql -c "create extension postgis;" dhis2 CREATE EXTENSION

2 Likes

Solution also above