Created
July 13, 2013 05:46
-
-
Save caitifty/5989575 to your computer and use it in GitHub Desktop.
Installing postgresql 9.1 postgis 2.0.3 geoserver 2.3.3 on Ubuntu 10.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This document describes installing geoserver 2.3.3 with postgresql 9.1 / postgis 2.0 on an ubuntu 10.04 server. The instructions were written from a base ubuntu server install on an amazon ec-2 instance but have also been used to install geoserver on a regular server running ubuntu 10.04 server. | |
These instructions basically follow the procedure from http://funnymonkey.com/install-geoserver-ubuntu except using the oracle jdk rather than use the open source one, since the oracle one has less problems with geoserver. | |
The instructions for postgresql / postgis came from: | |
http://www.whiteboardcoder.com/2012/04/install-postgres-91-on-ubuntu-1004-lts.html | |
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1004src | |
https://gist.github.com/djq/2846196 | |
https://gist.github.com/rolo/1481128 | |
## Install needed packages and ppas: | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get dist-upgrade | |
sudo apt-get -y install python-software-properties | |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
sudo add-apt-repository ppa:pitti/postgresql | |
sudo apt-get update | |
sudo apt-get install libnotify1 libsexy2 libwnck-common libwnck22 libxres1 notification-daemon zenity | |
sudo apt-get install unzip gdal-bin python-gdal | |
sudo apt-get -y install postgis postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgis gdal-bin binutils libgeos-3.2.2 libgeos-c1 libgeos-dev libgdal1-dev libxml2 libxml2-dev libxml2-dev checkinstall proj libpq-dev | |
sudo apt-get install build-essential | |
## Get & install the current java SE development kit from Oracle. | |
Go to: | |
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html | |
And download the current java SE development kit (ie jdk). You will need to create an account to do it. | |
where 'jdk-7u25-linux-x64.tar.gz' is the file you downloaded: | |
tar xvfz jdk-7u25-linux-x64.tar.gz | |
ls -lh | |
sudo mv jdk1.7.0_25/ /usr/lib/jvm | |
wget http://webupd8.googlecode.com/files/update-java-0.5b | |
chmod +x update-java-0.5b | |
sudo ./update-java-0.5b | |
Select jdk1.7.0_25 from the popup window. | |
sudo vi /etc/environment | |
add this to end: | |
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25 | |
sudo visudo | |
and add this to the end (note despite name it uses pico now not vi) | |
Defaults env_keep+=JAVA_HOME | |
Logout, log back in. | |
sudo echo $JAVA_HOME | |
should give /usr/lib/jvm/jdk1.7.0_25 | |
## Now install geoserver | |
wget http://downloads.sourceforge.net/geoserver/geoserver-2.3.3-bin.zip | |
unzip geoserver-2.3.3-bin.zip | |
sudo mv geoserver-2.3.3 /opt | |
sudo ln -s /opt/geoserver-2.3.3 /opt/geoserver | |
Check the bottom of http://geoserver.org/display/GEOS/Stable and see if you want any of the extensions. eg for mysql data store, gdal coverage, and ogr export, do: | |
cd ~ | |
mkdir geoserver_extensions | |
cd geoserver_extensions | |
wget http://downloads.sourceforge.net/geoserver/geoserver-2.3.3-mysql-plugin.zip | |
wget http://downloads.sourceforge.net/geoserver/geoserver-2.3.3-gdal-plugin.zip | |
wget http://downloads.sourceforge.net/geoserver/geoserver-2.3.3-ogr-plugin.zip | |
find . -name \*.zip -exec unzip -o {} \; | |
sudo cp -rp *.jar /opt/geoserver/webapps/geoserver/WEB-INF/lib/ | |
cd ~ | |
If you installed ogr, also do: | |
sudo vi /opt/geoserver/data_dir/ogr2ogr.xml (new file) and paste in: | |
<OgrConfiguration> | |
<ogr2ogrLocation>/usr/bin/ogr2ogr</ogr2ogrLocation> | |
<gdalData>/usr/share/gdal16</gdalData> | |
<formats> | |
<Format> | |
<ogrFormat>MapInfo File</ogrFormat> | |
<formatName>OGR-TAB</formatName> | |
<fileExtension>.tab</fileExtension> | |
</Format> | |
<Format> | |
<ogrFormat>MapInfo File</ogrFormat> | |
<formatName>OGR-MIF</formatName> | |
<fileExtension>.mif</fileExtension> | |
<option>-dsco</option> | |
<option>FORMAT=MIF</option> | |
</Format> | |
<Format> | |
<ogrFormat>CSV</ogrFormat> | |
<formatName>OGR-CSV</formatName> | |
<fileExtension>.csv</fileExtension> | |
<singleFile>true</singleFile> | |
<mimeType>text/csv</mimeType> | |
</Format> | |
<Format> | |
<ogrFormat>KML</ogrFormat> | |
<formatName>OGR-KML</formatName> | |
<fileExtension>.kml</fileExtension> | |
<singleFile>true</singleFile> | |
<mimeType>application/vnd.google-earth.kml</mimeType> | |
</Format> | |
</formats> | |
</OgrConfiguration> | |
sudo addgroup --system geoserver | |
sudo adduser --system --ingroup geoserver --no-create-home --disabled-password geoserver | |
cd /opt/geoserver/bin | |
sudo wget -O initd.sh http://docs.geoserver.org/latest/en/user/_downloads/geoserver_deb | |
sudo ln -s /opt/geoserver/bin/initd.sh /etc/init.d/geoserver | |
sudo chmod +x ./initd.sh | |
sudo vi initd.sh | |
Change "# Default-Stop: S 0 1 6" to: | |
# Default-Stop: 0 1 6 | |
sudo vi /etc/default/geoserver (new file) & insert: | |
#USER=geoserver | |
#GEOSERVER_DATA_DIR=/home/$USER/data_dir | |
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir | |
#GEOSERVER_HOME=/home/$USER/geoserver | |
GEOSERVER_HOME=/opt/geoserver | |
#PATH=/usr/sbin:/usr/bin:/sbin:/bin | |
#DESC="GeoServer daemon" | |
#NAME=geoserver | |
#JAVA_HOME=/usr/lib/jvm/java-6-sun | |
#DAEMON="$JAVA_HOME/bin/java" | |
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_25 | |
DAEMON="$JAVA_HOME/bin/java" | |
#JAVA_OPTS="-Xms128m -Xmx512m" | |
JAVA_OPTS="-Xms128m -Xmx512m -server" | |
#PIDFILE=/var/run/$NAME.pid | |
#SCRIPTNAME=/etc/init.d/$NAME | |
sudo chown -R geoserver:geoserver /opt/geoserver-2.3.3 | |
sudo update-rc.d geoserver defaults | |
sudo mkdir -p /opt/geoserver/webapps/geoserver/data/logs | |
sudo chown geoserver:geoserver /opt/geoserver/webapps/geoserver/data/logs/ | |
sudo /etc/init.d/geoserver start | |
should start it (it'll take a few minutes to come up completely. Login at: | |
http://localhost:8080/geoserver/web/ | |
Initial username/pwd is admin/geoserver. On first login you'll get security warnings, one of which will be about 'The administrator password for this server has not been changed from the default'. Click the 'change it' link beside the message, enter a new password, and click 'save'. | |
sudo rm /opt/geoserver-2.3.3/data_dir/security/users.properties.old | |
sudo mv /opt/geoserver-2.3.3/data_dir/security/masterpw.info ~ | |
Note the masterpw.info file contains the autogenerated (high security) password for the root geoserver user (not the admin server). You may want to read this file, store the password off-server, and delete the file. | |
to stop the server, do | |
sudo /etc/init.d/geoserver stop | |
## Post-install Postgres 9.1, install PostGIS and create PostGIS template: | |
cd ~ | |
wget http://download.osgeo.org/postgis/source/postgis-2.0.3.tar.gz | |
tar zxvf postgis-2.0.3.tar.gz && cd postgis-2.0.3 | |
./configure --with-raster --with-topology | |
make | |
sudo make install | |
cd ~ | |
sudo ln -s /usr/lib/postgresql/9.1/bin/shp2pgsql /usr/local/bin/shp2pgsql | |
sudo ln -s /usr/lib/postgresql/9.1/bin/pgsql2shp /usr/local/bin/pgsql2shp | |
sudo ln -s /usr/lib/postgresql/9.1/bin/raster2pgsql /usr/local/bin/raster2pgsql | |
sudo -u postgres psql postgres | |
\password postgres | |
{enter new password twice} | |
\q | |
sudo -u postgres createuser --superuser <your normal username> | |
sudo -u postgres psql | |
\password <your normal username> | |
{enter new password twice} | |
\q | |
createdb <your normal username> | |
Now you can just connect with: | |
psql | |
and create new databases from inside psql with: | |
create database <newname>; | |
To setup postgis template: | |
createdb -E UTF8 template_postgis2 | |
createlang -d template_postgis2 plpgsql | |
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis2'" | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_comments.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/rtpostgis.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/raster_comments.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology.sql | |
psql -d template_postgis2 -f /usr/share/postgresql/9.1/contrib/postgis-2.0/topology_comments.sql | |
psql -d template_postgis2 -c "GRANT ALL ON geometry_columns TO PUBLIC;" | |
psql -d template_postgis2 -c "GRANT ALL ON geography_columns TO PUBLIC;" | |
psql -d template_postgis2 -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" | |
Log in with psql and do: | |
CREATE EXTENSION postgis; | |
and to create a spatially enabled database: | |
createdb <newdb> -T template_postgis2 | |
Note if you already have a postgresql database and want to spatially enable it, run the commands above substituting your database name for 'template_postgis2'. | |
Finally, cleanup with | |
sudo apt-get update && sudo apt-get upgrade | |
sudo apt-get autoremove | |
sudo apt-get autoclean | |
sudo apt-get clean | |
You can also remove all the setupfiles: | |
cd ~ | |
rm -f geoserver-2.3.3-bin.zip | |
rm -rf geoserver_extensions | |
rm -f jdk-7u25-linux-x64.tar.gz | |
rm -rf postgis-2.0.3 | |
rm -f postgis-2.0.3.tar.gz | |
rm -f update-java-0.5b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment