If you are running PostgreSQL as a service from a cloud provider (not installing it yourself) then you probably
already
have PostGIS installed, and you just need to enable it in your database. Connect to your database as the
postgres
user or another super-user account, and run:
CREATE EXTENSION postgis;
Congratulations! PostGIS is now enabled.
Explore Your Install
You can find out what version you have, with
postgis_full_version()
.
SELECT PostGIS_Full_Version();
You can also check to see what alternate PostGIS versions might be installed.
SELECT * FROM pg_available_extensions WHERE name = 'postgis';
Learn about Spatial SQL
Start with the PostGIS Workshop for a hands-on guide to using spatial SQL for spatial data management and analysis.
Installing PostGIS
If you are just upgrading PostGIS, keeping the same PostgreSQL version, generally all you need to do is install the latest
PostGIS binaries and then in each of your spatial databases, run:
SELECT postgis_extensions_upgrade();
-- verify you are running latest now
SELECT postgis_full_version();
FOSS4G 2023: Upgrade your PostgreSQL and PostGIS video goes over why you should
upgrade your PostgreSQL and PostGIS, and steps to using pg_upgrade to do so.