Skip to content

Instantly share code, notes, and snippets.

@panchicore
Created August 3, 2011 15:03
Show Gist options
  • Save panchicore/1122841 to your computer and use it in GitHub Desktop.
Save panchicore/1122841 to your computer and use it in GitHub Desktop.
setup postgis on OSX 64-bits
#Download and install XCode
#Install homebrew (package manager) IF INSTALLED: just update it
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
#Install git
brew install git
#IF LION
sudo vi /etc/paths and move /usr/local/bin to the top, cuz LION comes with a specific osx restricted PG.
#Install the gis stack (geos, proj4, postgres, postgis, gdal)
#IF LEOPARD:
brew install postgis gdal
#IF LION:
brew install postgis gdal --use-gcc
#WORKARROUND TO INSTALL OLD VERSION FORMULA http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula
brew versions postgres
brew versions postgis
# IF MOUNTAIN LION
(install the stable formula for postgis 1.5.3 not 2.0.1)
brew install https://raw.github.com/mxcl/homebrew/8a04a43763906e6a9bef68881acf997f3a6f6687/Library/Formula/postgis.rb
# Note the instructions to take it up and down on a development machine:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.3/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
PG ready!
$ psql --version
$ createdb holamundo
$ psql holamundo
Download and install XCode
#Install homebrew (package manager)
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
#Install git
brew install git
#Install the gis stack (geos, proj4, postgres, postgis, gdal)
brew install postgis gdal
# Note the instructions to take it up and down on a development machine:
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.3/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
brew install pip
brew install exiftool
brew install libevent
brew install node
pip install ipython
pip install virtualenv
pip install docutils
pip install python-dateutil
pip install Markdown==2.0.3
pip install PyYAML
pip install ZSI
pip install python-memcached
pip install smartypants
pip install vobject
pip install httplib2
pip install ftputil==2.2.3
pip install geopy
pip install psycopg2
pip install mimeparse
pip install lxml
pip install gevent
-------------------------
Este fue mi stacktrace de mi maquina:
(peakery)panchicore:appery luispallareslopez$ brew install postgis gdal
==> Downloading http://www.mirrorservice.org/sites/ftp. … 6.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-debug --without-perl --without-php --without-pgsql --prefix=/usr/local/Cellar/ossp-uuid/1
==> make
==> make install
/usr/local/Cellar/ossp-uuid/1.6.2: 11 files, 364K, built in 7 seconds
==> Downloading http://ftp9.us.postgresql.org/pub/mirro … .3.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.0.3 --enable-thread-safety --with-bonjour -
==> make install
==> cd contrib/adminpack; make install
==> cd contrib/auto_explain; make install
==> cd contrib/btree_gin; make install
==> cd contrib/btree_gist; make install
==> cd contrib/chkpass; make install
==> cd contrib/citext; make install
==> cd contrib/cube; make install
==> cd contrib/dblink; make install
==> cd contrib/dict_int; make install
==> cd contrib/dict_xsyn; make install
==> cd contrib/earthdistance; make install
==> cd contrib/fuzzystrmatch; make install
==> cd contrib/hstore; make install
==> cd contrib/intagg; make install
==> cd contrib/intarray; make install
==> cd contrib/isn; make install
==> cd contrib/lo; make install
==> cd contrib/ltree; make install
==> cd contrib/oid2name; make install
==> cd contrib/pageinspect; make install
==> cd contrib/passwordcheck; make install
==> cd contrib/pg_archivecleanup; make install
==> cd contrib/pg_buffercache; make install
==> cd contrib/pg_freespacemap; make install
==> cd contrib/pg_standby; make install
==> cd contrib/pg_stat_statements; make install
==> cd contrib/pg_trgm; make install
==> cd contrib/pg_upgrade; make install
==> cd contrib/pg_upgrade_support; make install
==> cd contrib/pgbench; make install
==> cd contrib/pgcrypto; make install
==> cd contrib/pgrowlocks; make install
==> cd contrib/pgstattuple; make install
==> cd contrib/seg; make install
==> cd contrib/spi; make install
==> cd contrib/sslinfo; make install
==> cd contrib/tablefunc; make install
==> cd contrib/test_parser; make install
==> cd contrib/tsearch2; make install
==> cd contrib/unaccent; make install
==> cd contrib/uuid-ossp; make install
==> cd contrib/vacuumlo; make install
==> cd contrib/xml2; make install
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.0/stat … edure.html
If this is your first install, create a database with:
initdb /usr/local/var/postgres
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.3/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
cp /usr/local/Cellar/postgresql/9.0.3/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
Or start manually with:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
And stop with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
==> Summary
/usr/local/Cellar/postgresql/9.0.3: 1305 files, 21M, built in 2.0 minutes
==> Downloading http://download.osgeo.org/proj/proj-4.7.0.tar.gz
######################################################################## 100.0%
==> Downloading http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/proj/4.7.0 --disable-debug --disable-dependency-tracking
==> make install
/usr/local/Cellar/proj/4.7.0: 48 files, 5.6M, built in 41 seconds
==> Downloading http://download.osgeo.org/geos/geos-3.2.2.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/geos/3.2.2 --disable-debug --disable-dependency-tracking
==> make install
/usr/local/Cellar/geos/3.2.2: 355 files, 7.7M, built in 2.4 minutes
==> Downloading http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/postgis/1.5.2 --with-projdir=/usr/local
==> make install
==> Caveats
To create a spatially-enabled database, see the documentation:
http://postgis.refractions.net/documentation/manual-1.5.2/ch02.html#id2786223
==> Summary
/usr/local/Cellar/postgis/1.5.2: 15 files, 5.1M, built in 23 seconds
==> Downloading http://downloads.sourceforge.net/projec … .6.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/giflib/4.1.6 --disable-debug --disable-dependency-tracking
==> make install
/usr/local/Cellar/giflib/4.1.6: 36 files, 708K, built in 12 seconds
==> Downloading http://download.osgeo.org/gdal/gdal-1.8.0.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gdal/1.8.0 --disable-debug --with-local=/usr/local/Cellar/gdal/1.8.0 --w
==> make
==> make install
==> python setup.py install_lib --install-dir=/usr/local/Cellar/gdal/1.8.0/lib/python
==> Caveats
This version of GDAL was built with Python support. In addition to providing
modules that makes GDAL functions available to Python scripts, the Python
binding provides ~18 additional command line tools. However, both the Python
bindings and the additional tools will be unusable unless the following
directory is added to the PYTHONPATH:
/usr/local/lib/python
==> Summary
/usr/local/Cellar/gdal/1.8.0: 167 files, 28M, built in 4.9 minutes
@panchicore
Copy link
Author

this works OK in Lion with the next changes:

brew update
brew install postgis gdal --use-gcc

@panchicore
Copy link
Author

On Mac OS X Lion, vi /etc/paths and move /usr/local/bin to the top. Save, exit terminal, type brew doctor and you should see something that says, "raring in brew". If you run brew doctor before modifying paths, you will see an error from brew.

@oskamaya
Copy link

TO INSTALL THE OLD POSTGIS: https://gist.github.com/2429181


OPTIONAL

to add the postgis template:

cd /usr/local/Cellar/postgis/2.0.0/share/postgis/
createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsql
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
psql -d template_postgis -f postgis.sql
psql -d template_postgis -f spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"

@panchicore
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment