So far I have install and worked with Leaflet & GeoServer. In order to complete the full stack web GIS solution the database component. The most common (open source) software for this option is the PostgreSQL/PostGIS.
In my case that I am using Mac (macOS High Sierra V10.13.6), the work-through that I followed is based on this post and it is as follows:
- assuming that homebrew is installed
- assuming that no previous version of Postgres is installed (has to be uninstalled)
- open terminal and install Postgres:
brew install postgres
- install PostGIS
brew install postgis
The previous steps might take quite some time due to the fact that there are several dependencies. Additional software will be installed (or updated) like: freexl, gdbm, sqlite, python@2, geos, giflib, jpeg, json-c, libtiff, proj, libgeotiff, libpng, libpq, libxml2, libspatialite, xz, python, numpy, pcre, zstd, gdal, boost, gmp, mpfr, cgal, sfcgal
- start the PostgreSQL server
pg_ctl -D /usr/local/var/postgres start
Defaults for PostgreSQL are:
- address: 127.0.0.1
- port: 5432
- user & password the same as the user who created the PostgreSQL
- Create Database
initdb /usr/local/var/postgres
If terminal shows an error
initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".
Remove old database file
rm -r /usr/local/var/postgres
Run the initdb command again
initdb /usr/local/var/postgres
In case this wont work, restart the terminal.
- Instead of continue working on the terminal I prefer to use the pgAdmin. Download the software in the pgAdmin download site.
- On the pgAdmin browser user interface select the server and log in (if required) using your credentials. Select databases and then from menu Object>Create>Database. Give a name to the database and create it.
- Select the new database on the left pane. Select from the menu Tools/Query tool
- Give the below query to create the PostGIS extension on the DB.
CREATE EXTENSION postgis;
- In order to verify repeat but give the query
SELECT PostGIS_Version();
As a result there should the PostGIS version used in the DB.