How to install Qgis3.2 + Grass7 + PGAdmin4 + Postgres11 + Postgis2.5 in Ubuntu Bionic

To start the installation, you must to add the following lines to your /etc/apt/sources.list file:

# qgis
deb http://qgis.org/debian bionic main
deb-src http://qgis.org/debian bionic main

# pgadmin4
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main 11

Now, you need to get the repositories keys with the following sentences:

# qgis
gpg --keyserver keyserver.ubuntu.com --recv CAEB3DC3BDF7FB45
gpg --export --armor CAEB3DC3BDF7FB45 | sudo apt-key add -

# pgadmin4
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Now, proceed with installation:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql postgresql-contrib postgresql-11-postgis-2.5-scripts pgadmin4 qgis python-qgis qgis-plugin-grass -y

To configure postgres, we procced to create a database with a postgres user:

sudo -u postgres createdb testing
psql -d testing -c "create extension postgis"

Probably you will get the following issue:

ERROR:  permission denied to create extension "postgis"

HINT:  Must be superuser to create this extension.

To fix it, you must access like postgres user.
You can create a ~/.pgpass file with the following content to avoid enter the password every time:

hostname:port:db_name:user:password

Other option is use PGPASSWORD to avoid interactive password input.

PGPASSWORD=postgres psql 'host=localhost port=5432 dbname=testing user=postgres' 
testing=# CREATE EXTENSION postgis WITH SCHEMA public;
ERROR:  could not access file "$libdir/postgis-2.5": No such file or directory

Postgres can't find postgis-2.5 in $libdir. To check $libdir path execute this command in bash.

pg_config --pkglibdir
/usr/lib/postgresql/11/lib

In fact, no postgis file exists in this folder. We need to install it:


sudo apt install postgresql-11-postgis-2.5

Now, proceed again to create postgis extension

testing=# CREATE EXTENSION postgis WITH SCHEMA public;

Don't forget change your postgres user password:

sudo -u postgres psql   
postgres=# \password postgres
Enter new password: 
Enter it again: 
postgres=# \q

Enjoy!


Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

from: can't read /var/mail/ in Python scripts

Fix "Set scan parameters failed: Input/output error" on Ubuntu 16.04