| 1 | The [http://wiki.postgresql.org/wiki/Apt PostgreSQL Apt Repository] now hosts installs of PostGIS, in addition to Postgresql and PGAdmin3. |
| 2 | |
| 3 | The following describes how to install Postgresql 9.3, PostGIS 2.1, PGAdmin 1.18.1 and shp2pgsql-gui on Ubuntu versions 12.04 through 13.10. |
| 4 | |
| 5 | == Add Respository to sources.list == |
| 6 | |
| 7 | Run in terminal: |
| 8 | |
| 9 | {{{sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list'}}} |
| 10 | |
| 11 | {{{wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -}}} |
| 12 | |
| 13 | {{{sudo apt-get update}}} |
| 14 | |
| 15 | == Install == |
| 16 | The following will install postgresql 9.3, PostGIS, PGAdmin3, and additional supplied modules including {{{adminpack}}} |
| 17 | |
| 18 | {{{sudo apt-get install postgresql-9.3-postgis pgadmin3 postgresql-contrib}}} |
| 19 | |
| 20 | == Enable Adminpack == |
| 21 | |
| 22 | While in terminal, log in to psql as postgres user: |
| 23 | |
| 24 | {{{sudo -u postgres psql}}} |
| 25 | |
| 26 | {{{CREATE EXTENSION adminpack;}}} |
| 27 | |
| 28 | Quit psql: |
| 29 | |
| 30 | {{{\q}}} |
| 31 | |
| 32 | == Create new PGSQL user == |
| 33 | |
| 34 | You can create a new database super user to use instead of the default {{{postgres}}} user. |
| 35 | |
| 36 | While in terminal, run: |
| 37 | |
| 38 | {{{sudo su - postgres}}} |
| 39 | |
| 40 | {{{createuser -d -E -i -l -P -r -s yourUserName}}} (be sure to change the username to your desired username) |
| 41 | |
| 42 | Enter your new password when prompted |
| 43 | |
| 44 | Log out as {{{postgres}}} user: |
| 45 | |
| 46 | {{{exit}}} |
| 47 | |
| 48 | Exit terminal: |
| 49 | |
| 50 | {{{exit}}} |
| 51 | |
| 52 | == Use PGAdmin to log into database server == |
| 53 | |
| 54 | From the Ubuntu launcher, type in PGAdmin to reveal the application |
| 55 | |
| 56 | Fill in the necessary credentials to log in: |
| 57 | |
| 58 | {{{ |
| 59 | - Name: nickname you want to give your connection |
| 60 | - host: localhost (until you change the connection settings) |
| 61 | - port: 5432 by default |
| 62 | - maintenance DB: postgres by default |
| 63 | - username: whatever you chose in the step above |
| 64 | - password: whatever you chose in the step above |
| 65 | }}} |
| 66 | |
| 67 | == Enable postgis extensions on new database == |
| 68 | |
| 69 | Since you installed PostgreSQL and PostGIS from the PostgreSQL apt repository, you now have all the extensions for PostgreSQL, including PostGIS |
| 70 | |
| 71 | Expand the database tree in PGAdmin, and reveal the extensions node |
| 72 | |
| 73 | Right-click the extensions node, and click {{{new extension}}} |
| 74 | |
| 75 | Enable the {{{postgis}}} extension, as well as {{{postgis_topology}}} |
| 76 | |
| 77 | == Test shp2pgsql-gui == |
| 78 | |
| 79 | Another handy piece of software to use is the {{{shp2pgsql-gui}}} tool. This will allow you to quickly connect to your new PostGIS database and import a Shapefile. |
| 80 | |
| 81 | Open terminal, and type: |
| 82 | |
| 83 | {{{shp2pgsql-gui}}} |
| 84 | |
| 85 | Follow the on-screen prompts to load your data. |
| 86 | |
| 87 | For more information, visit the [http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_tut01 Boston GIS] tutorial in the section "Load Towns Data" |
| 88 | |
| 89 | |