Changes between Initial Version and Version 1 of UsersWikiPostgisOnUbuntu


Ignore:
Timestamp:
Apr 13, 2009, 2:44:39 PM (15 years ago)
Author:
pierre
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiPostgisOnUbuntu

    v1 v1  
     1
     2= How To Install PostGIS on Ubuntu (draft) =
     3
     4== Installation ==
     5
     6=== From Packages (aka, the easy way): ===
     7
     8
     9PostGIS and Postgresql are available as packages for Ubuntu 6.10 and greater. To install, use either:
     10
     11        apt-get install postgresql-8.3-postgis postgis
     12
     13'''OR'''
     14
     15Use adept or synaptic and select packages:
     16
     17postgresql-8.3-postgis
     18
     19postgis
     20
     21'''NOTE:''' The "Universe" repository must be enabled.
     22
     23'''NOTE:''' postgresql-8.3 is current as of 1/2009. You should, of course, use the current version.
     24
     25=== From Source (aka, the hard way): ===
     26
     27 1. Install Postgresql, Libgeos, Proj. packages.  Easiest way is to use Synaptic (be sure to include Universe in your respositories).  Also be sure to install the "-dev" packages (postgresql-server-dev-8.0).  Under Breezy, latest postgresql version is 8.0 (adjust following paths to reflect the version you have installed).
     28
     29 2. Download postgis.tgz and place in  /usr/share/postgresql/8.0/contrib
     30
     31 3. Extract the via Nautilus or cd to the directory and then use tar -zvxf postgis-x.x.x
     32
     33 4. Now cd to the postgis directory.
     34
     35 5. Now configure.  Try:
     36
     37{{{
     38  > sudo ./configure --prefix=/usr  --with-pgsql=/usr/bin/pg_config
     39    --with-geos=/usr/bin/geos-config  --with-proj=/usr
     40
     41}}}
     42
     43
     44 6. Check to see that you have no errors.  You may need to install other packages (like flex and byacc).
     45
     46 7. Now type > sudo make
     47
     48 8. type > sudo make install
     49
     50That should do it.
     51
     52----
     53
     54== Using PostGIS ==
     55
     56 1. Create a database.  You must be the '''postgres''' superuser to do this: =
     57 From the shell:
     58
     59        $ createdb mytestdb
     60
     61 '''TIP:''' if you get permission errors, try:
     62
     63        $ sudo su postgres
     64        $ createdb mytestdb
     65
     66 '''REMEMBER:''' type 'exit' when you're done with these postgres commands to return to your normal user.
     67
     68 2. Set up the postgis libs:
     69
     70        $ createlang plpgsql mytestdb
     71
     72 2a. If you installed from packages:
     73
     74        $ psql -d mytestdb -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
     75
     76 if there were no errors (if the last line of output is COMMIT), then
     77
     78        $ psql -d mytestdb -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
     79
     80 '''NOTE:''' Fedora 7 installed from package path is /usr/share/pgsql/contrib/
     81
     82 2b. If you installed from source:
     83
     84 '''NOTE:''' this looks old...
     85
     86        $ psql -d mytestdb -f /usr/share/postgresql/8.0/contrib/postgis-1.1.1/lwpostgis.sql
     87
     88        $ psql -d mytestdb -f /usr/share/postgresql/8.0/contrib/postgis-1.1.1/spatial_ref_sys.sql
     89
     90 3. Make sure that your DB user has GRANT ALL on the "geometry_columns" table and GRANT SELECT on "spatial_ref_sys". =
     91
     92 '''Now import a shp file:'''
     93
     94        $ shp2pgsql -D myshape.shp mytable mytestdb | psql mytestdb
     95
     96 This will take the input file "myshape.shp" and create a new table, "mytable" in the database "mytestdb."
     97
     98 To see if your shape file is there:
     99
     100        $ psql mytestdb
     101        mytestdb=# SELECT * from mytable;