I found this question on stack overflow and answered it – then the pedantic site moderators deleted it. So here is the answer again.

On a clean install of postgres and postgis you will see this error because postgis doesn’t have the dependency to pull in the shared library. When you go into psql the command

my_database=# CREATE EXTENSION postgis;

returns:

ERROR: could not access file “$libdir/postgis-2.1”: No such file or directory

found I also needed

sudo apt-get install postgresql-9.4-postgis-2.1

I found it by looking at

apt-cache search postgres | grep gis
Facebooktwittergoogle_plusredditmail