Updated MacPostGIS_Setup (markdown)

ThomasG77 2011-12-27 10:55:05 -08:00
parent d25fcce7e6
commit 79d86fd77d

@ -5,40 +5,50 @@
## Mac PostGIS / Postgres Setup ## Mac PostGIS / Postgres Setup
After you have installed PostgreSQL and PostGIS you will need to perform further setup before you can begin to use them with mapnik. After you have installed PostgreSQL and PostGIS you will need to perform further setup before you can begin to use them with mapnik.
* Setup for *Binaries/Frameworks* from [kyngchaos.com](http://www.kyngchaos.com/wiki/software:frameworks). * Setup for *Binaries/Frameworks* from [kyngchaos.com](http://www.kyngchaos.com/wiki/software:frameworks).
* Add the bin and man page directories to your path (assumes bash shell which is default on 10.5). You may create or append the ~/.profile with the following: * Add the bin and man page directories to your path (assumes bash shell which is default on 10.5). You may create or append the ~/.profile with the following:
#!sh ```sh
export PATH=/usr/local/pgsql/bin:$PATH export PATH=/usr/local/pgsql/bin:$PATH
export MANPATH=/usr/local/pgsql/man:$MANPATH export MANPATH=/usr/local/pgsql/man:$MANPATH
```
* Register your changes * Register your changes
#!sh ```sh
$ source ~/.profile $ source ~/.profile
```
You should now be able to type the following from any directory and see the man page. You should now be able to type the following from any directory and see the man page.
#!sh ```sh
$ man psql $ man psql
```
* Create a database. The installer you used from [kyngchaos.com](http://www.kyngchaos.com/wiki/software:frameworks) automatically created a Mac OS user on your system named postgres. Use that user to create a new database user/role and setup the database. (change "gisuser" to your liking) * Create a database. The installer you used from [kyngchaos.com](http://www.kyngchaos.com/wiki/software:frameworks) automatically created a Mac OS user on your system named postgres. Use that user to create a new database user/role and setup the database. (change "gisuser" to your liking)
#!sh ```sh
$ sudo -u postgres -i $ sudo -u postgres -i
$ createuser gisuser $ createuser gisuser
$ createdb -E UTF8 -O gisuser mapnik $ createdb -E UTF8 -O gisuser mapnik
$ createlang plpgsql mapnik $ createlang plpgsql mapnik
```
* Alternatively you can run all commands from your normal shell user but use the '-U' flag to call them as the postgres user: * Alternatively you can run all commands from your normal shell user but use the '-U' flag to call them as the postgres user:
#!sh ```sh
$ createdb -E UTF8 -U postgres <dbname> $ createdb -E UTF8 -U postgres <dbname>
$ createlang plpgsql -U postgres <dbname> $ createlang plpgsql -U postgres <dbname>
```
* PostGIS support must be enabled for each database that requires its usage. This is done by feeding the lwpostgis.sql (the enabler script) file to the target database. * PostGIS support must be enabled for each database that requires its usage. This is done by feeding the lwpostgis.sql (the enabler script) file to the target database.
#!sh ```sh
$ psql -d mapnik -f /usr/local/pgsql/share/lwpostgis.sql $ psql -d mapnik -f /usr/local/pgsql/share/lwpostgis.sql
$ psql -d mapnik -f /usr/local/pgsql/share/spatial_ref_sys.sql $ psql -d mapnik -f /usr/local/pgsql/share/spatial_ref_sys.sql
$ echo "ALTER TABLE geometry_columns OWNER TO gisuser; ALTER TABLE spatial_ref_sys OWNER TO gisuser;" | psql -d mapnik $ echo "ALTER TABLE geometry_columns OWNER TO gisuser; ALTER TABLE spatial_ref_sys OWNER TO gisuser;" | psql -d mapnik
```
At this point your database should be setup to create a PostGIS table. At this point your database should be setup to create a PostGIS table.
TODO - full example showing PostGIS use. TODO - full example showing PostGIS use.