While MapServer is written in the C language and uses Apache as its web server, GeoServer is written in Java and you therefore need to install the Java Virtual Machine (JVM) in your system; it must be used from a servlet container, such as Jetty and Tomcat. After installing the servlet container, you will be able to deploy the GeoServer application to it. For example, in Tomcat, you can deploy GeoServer by copying the GeoServer WAR (web archive) file to Tomcat's webapps directory. For this recipe, we will suppose that you have a working GeoServer in your system; if this is not the case, follow the detailed GeoServer installation steps for your OS at the GeoServer website (http://docs.geoserver.org/stable/en/user/installation/) and then return to this recipe. Follow these steps:
- Download the USA counties shapefile from the https://nationalmap.gov/ website at http://dds.cr.usgs.gov/pub/data/nationalatlas/countyp020_nt00009.tar.gz (this archive is included in the book's code bundle). Extract the archive from working/chp09 and import it to PostGIS using the ogr2ogr command, as follows:
$ ogr2ogr -f PostgreSQL -a_srs EPSG:4326 -lco GEOMETRY_NAME=the_geom
-nln chp09.counties PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" countyp020.shp