Give your database some GIS sugar!
Well, its time for production now - remember that tutorial way back about building PostGRE on OSX? Well Ive just done it on Ubuntu Server, but from scratch, with all the GIS bells and whistles ;)
Lets tuck in…
First off, rather than me labour the point (anyone familiar with linux will breeze this part) check out this really usefull post - its got all the things you need for doing the actual compilation and install.
There are however a few Ubuntu related “gotchas”. Firstly, after you install GEOS, both ldconfig doesnt yet know about the new libs you’ve just installed at /usr/local/lib. To make it read the new libs you’ve gotta create a new file called ld.so.conf and stick it in /etc - fill it with the following:
<code>/lib/ /usr/lib/ /usr/local/lib/ /usr/X11R6/lib/</code>
Then to make it read in the new config, do this:
<code>/sbin/ldconfig -f /etc/ld.so.conf</code>
To check that its now reading your GEOS libs, run the following, and make sure you see a similar output (depending on the version of GEOS you installed)
<code>$ /sbin/ldconfig -p | grep geos libgeos_c.so.1 (libc6,x86-64) => /usr/local/lib/libgeos_c.so.1 libgeos_c.so (libc6,x86-64) => /usr/local/lib/libgeos_c.so libgeos.so.2 (libc6,x86-64) => /usr/lib/libgeos.so.2 libgeos.so (libc6,x86-64) => /usr/lib/libgeos.so</code>
Another helping sir?
OK - were good to go on that front. The key thing now is that we need to be able to add GIS functions and type handlers to any given database. Provided you set up the ldconfig stuff correctly, doing:
<code>su -- postgres /usr/local/pgsql/bin/psql \ -f /usr/local/pgsql/share/lwpostgis.sql \ -d yourdbnamegoeshere</code>
If this didnt work, you have a problem with your ldconfig! There are fixes out there which advise changing the lwpostgis.sql script, but in my personal opinion, thats not fixing the problem, thats just dirtying a fresh install.
Next, after I had everything up and running, it was puzzling me that there was no init.d script available (the google force was not strong today), I rummaged around in the source I downloaded, and found a startup-scripts dir in the contrib directory, result. Take that script, and bosh it into /etc/init.d and do:
<code>sudo /usr/sbin/update-rc.d postgresql-8.2.5 defaults</code>
Then you have a fully working PostGRE install with GIS sugar!!!
Hopefully this might help someone one day :)