To install PostgreSQL on the command line we will be using a package manager called Homebrew. If you already have Homebrew installed, you can skip to Installing PostgreSQL. This is the GUI that I use to manage Postgres because it is built specifically for Mac and has a beautiful, very easy to use (but powerful) UI. It also includes an SQL.
On Mac OSX
Because of Homebrew, installation is easier on Mac. Run these two commands to install bothpostgresql and PostGIS
It is done, how nice!
Start the service
type this command to start the postgresql service.
![Install Postgis For Postgres On Mac Install Postgis For Postgres On Mac](/uploads/1/2/5/8/125840190/987539832.png)
then check if the service is up and running.
Make sure postgresql starts when mac starts up
If you don’t want to run the above start command every time you start your mac, do the following to make surepostgresql automatically starts.
- make sure you have this directory
~/Library/LaunchAgents
. (create it if it does not exist) - run
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
to create a symbolic link for postgres plistfile - run
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
to add the plist to launch control.
Postgresql should start automatically every time your mac starts.
On AWS Ubuntu
Remote login to aws ubuntu instance, then run the following:
After installation, you can create database by running
sudo -u postgres createdb DATABASE_NAME
![Postgres Postgres](/uploads/1/2/5/8/125840190/111291274.jpg)
If you want to create a specific user for a database, run
Then you can test database connection by running
psql -U USER_NAME DATABSE_NAME
Install PostGIS
After postgresql is installed and connection tested, we can install postgis:
9.* is the version of your postgresql, and 2.* the version of PostGIS
Then you can create PostGIS extension for your regular postgresql database to enable GIS functions.
In psql session, do this to enable PostGIS and check if extension is created.
Notes: if you use a created database user, make sure it has super role to create extension. If you are using GeoDjango,migrate database using django manage.py command will create the extension automatically.
Install PgAdmin III and connect to database
PgAdmin III is a s a comprehensive PostgreSQL database design and management system
go to http://www.pgadmin.org/download/macosx.php to download and installit.
After install, you can create a db connection to connect to your postgresql and PostGIS databases.
It is pretty straightforward to connect to a local database, just provide the localhost/port(default 5432) database username and password (if you have a password, or leave it empty).
If you want to connect to a remote database on AWS instance, you need to make some changes to config files
in /etc/postgresql/9.*/main/postgresql.conf add
listen_addresses='*'
in /etc/postgresql/8.2/main/pg_hba.conf add
host all all 0.0.0.0/0 md5
Because port 5432 (your postgresql port) may not be open by default security settings, you need to open it appropriately.On amazon, you can add that rule in your security group of the instance in aws console.
After the changes, you should be able to connect to your remote database from your local machine.
Published
Tags
PostGIS has many packaged installations, but if you are more adventurousand want to compile your own, refer to our source download and compilationinstructions:
Binary distributions of PostGIS are available for various operating systems.
Windows
- More details about getting up and running with windows can be found on Windows Downloads page.
OSX
- A popular distribution particularly for newbies is Postgres.app. It includes generally latest version of PostgreSQL, PostGIS, and PLV8.Great for development and testing. Do not mix with other installations.
- Homebrew users can just run “brew install postgis” and tends to be a favorite for more advanced users since there are brew scriptsfor most of the popular PostgreSQL extensions, not always present in other Mac distributions.
- The EnterpriseDb OSX PostgreSQL combination from EnterpriseDB includes generally latest stable minor version of PostGIS.
- The builds from KyngChaos are a little dated but useful for older PostGIS versions. Read the instructions carefully.Do not mix with other installations.
Red Hat / Centos / Scientific Linux
- The best place to get the latest binaries for both PostgreSQL and PostGIS is the PostgreSQL Yum repository
- Choose the correct “repository RPM” for your distribution, download and install it.
- Install PostGIS and dependencies by running
yum install postgis2_93
. (where 93 refers to minor version of PostgreSQL you installed. - Refer to Install PostgreSQL 9.5, PostGIS 2.2, pgRouting 2.1 with Yum for more detailed instructions.
Ubuntu / Debian
- UbuntuGIS project has PostGIS and other OSGeo project offerings
- The PostgreSQL build team has packages for Debian and Ubuntu for several versions of PostgreSQL and PostGIS APT repository for PostgreSQL builds. PostgreSQL Apt Repo PostGIS 2.4 install covers 10
- The Debian GIS project maintains PostGIS packaging for Debian also used by Ubuntu and UbuntuGIS.
OpenSUSE and SUSE
- OpenSUSE PostGIS 2.1 For OpenSUSE 13.1, 12.3, Tumbleweed, SUSE SLE-11 SP 3
Distributions targeting more than one OS (these include PostgreSQL and many other PostgreSQL extensions)
- BigSQL - Supports 64-bit for Linux (RedHat, Debian), MacOSX 64-bit, and Windows 64-bit.It generally has latest version of PostGIS and ogrfdw for all OS supported. As such, it’s ideal if you have users on different OS and want a consistent set of PostGIS related features for all.Refer to BigSQL: PostGIS Install and BigSQL: How to create a Spatial Database for PostGIS specific install instructions.
- EnterpriseDb PostgreSQL - Supports 32-bit/64-bit Linux, MacOSX, WindowsNote that the MacOSX PostGIS packageand EDB Windows PostGIS package have different maintainers, so offerings are not equivalent.Both versions generally have latest minor version of PostGIS, but versions of libraries used may be different,other PostGIS related extensions like pgRouting, postgis_sfcgal are packaged with the windows but not OSX version.