| 62 | * Then make sure that the postgresql programs are on your path or in .bash_profile |
| 63 | {{{ |
| 64 | Export PATH=/usr/lib/postgresql/8.3/bin/ |
| 65 | }}} |
| 66 | * Open up access in the pg_hba.conf file |
| 67 | {{{ |
| 68 | sudo vim /etc/postgresql/8.2/main/pg_hba.conf |
| 69 | #change ident sameuser to trust |
| 70 | # comment out this line to allow, for instance, to django/psycopg2 to connect without password |
| 71 | local all postgres ident sameuser |
| 72 | }}} |
| 73 | * Restart the server by switching into the default user |
| 74 | {{{ |
| 75 | sudo su - postgres |
| 76 | pg_ctl -o -i -D /var/lib/postgresql/8.3/main/ restart |
| 77 | }}} |
| 78 | |
| 79 | |
| 80 | === Step 5 === |
| 81 | Apt-get install postgis, libgdal, libgeos, and proj |
| 82 | * Note: search for the exact package names with |
| 83 | {{{ |
| 84 | apt-cache search GIS_LIB_NAME |
| 85 | }}} |
| 86 | |
| 87 | {{{ |
| 88 | apt-get install postgresql-8.2-postgis libgeos-dev libgeos-c1 libgdal1-dev proj |
| 89 | }}} |
| 90 | |
| 91 | === Step 6 === |
| 92 | Create your PostGIS database |
| 93 | {{{ |
| 94 | # Switch to the default postgres user |
| 95 | sudo su - postgres |
| 96 | # Create a template database with UTF encoding owned by the postgres user (or your user of choice) |
| 97 | createdb -E UTF8 -O postgres -U postgres template_postgis |
| 98 | # Now you can switch back to your normal user |
| 99 | exit |
| 100 | # Load the required procedural language for postgis |
| 101 | createlang plpgsql -d template_postgis -U postgres |
| 102 | # Load optional languages |
| 103 | # Load postgis functions and spatial reference info |
| 104 | # which likely was installed in the postgres share directory |
| 105 | pg_config --sharedir |
| 106 | /usr/local/pgsql/share |
| 107 | # Also look for lwpostgis.sql and spatial_ref_sys.sql in: |
| 108 | ls /usr/share/ # or /usr/local/share/ |
| 109 | psql -d template_postgis -U postgres -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql |
| 110 | # Note: ignore any NOTICES, like 'psql:/usr/share/lwpostgis.sql:44: NOTICE: type "histogram2d" is not yet defined' |
| 111 | # You should see output like: |
| 112 | BEGIN |
| 113 | CREATE FUNCTION |
| 114 | CREATE OPERATOR |
| 115 | [...] |
| 116 | CREATE TYPE |
| 117 | CREATE AGGREGATE |
| 118 | COMMIT |
| 119 | # If you get an error about not being able to find `geos` add: |
| 120 | /usr/local/lib to /etc/ld.so.conf |
| 121 | # And run: |
| 122 | ldconfig # Then restart PostgreSQL |
| 123 | # Then load the geographic projections table |
| 124 | psql -d template_postgis -U postgres -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql |
| 125 | }}} |
| 126 | |
| 127 | Whoa! Hopefully that worked, and you will only have to do it once! |
| 128 | |
| 129 | From then on create a PostGIS database like: |
| 130 | {{{ |
| 131 | createdb -U postgres -T template_postgis DB_NAME |
| 132 | }}} |
| 133 | |
| 134 | === Step 7 === |
| 135 | Return to GeoDjangoInstall for troubleshooting and tests for GDAL and GEOS (see bottom of page) |