Required
--------
Do this as root.
# yum install libpng libpng-devel
# yum install freetype
# yum install gd gd-devel
# yum install zlib
# yum install giflib-devel
Recommended
-----------
If gcc not installed, install it so that proj can compile. Do this as root.
# yum install gcc
# http://download.osgeo.org/proj/proj-4.8.0.tar.gz
# gunzip, then untar, create /opt/proj-4.8.0
# cd /opt/proj-4.8.0
# ./configure
# make
# make check
# make install
# yum install libcurl
As root Install of OGR and GDAL
-----------------------
# yum install http://elgis.argeo.org/repos/5/elgis-release-5-5_0.noarch.rpm
# yum install agg agg-devel
# yum install readline-devel
# yum install zlib-devel
# yum install libxml2-devel
# yum install geos-devel
# yum install gcc-c++
# yum install curl-devel
Optional
--------
# yum install libtiff
# yum install libgeotiff
# yum install libjpeg
# yum install geos
# yum install libxml2
As root Install PostgreSQL
------------------
# tar xvf postgresql-9.1.3.tar.gz
# cd /opt/postgresql-9.3.1
# cd /usr/lib64
# ln -s /lib64/libreadline.so.6.0 libreadline.so.6.0
# ./configure
# gmake
# gmake install
# adduser postgres
# mkdir /usr/local/pgsql/data
# chown postgres /usr/local/pgsql/data
# su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
As root Install geos-3.3.3
-------------------
# cd /opt/geos-3.3.3
# ./configure
# make
# make install
As root Install gdal-1.9.0
------------------
# cd /opt/gdal-1.9.0
# ./configure
# make
# make install
As root and postgres Install PostGIS
------------------------------
Download postgis-x.y.z.tar.gz
# chown postgres: -R /opt/postgis-2.0.0
# su - postgres
$ cd /opt/postgis-2.0.0
$ ./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --libdir=/usr/lib64
$ make
make check will throw errors about permissions
----------------------------------------------
change perms to 777, re-run make check then change perms back
-------------------------------------------------------------
$ make check
$ make install
As root Install gd (even though installed w/yum)
----------------------------------------
# cd /opt/gd
# ./configure
# make
# make install
As root Install mapserver-6.0.2
-----------------------
# ./configure --with-ogr=/usr/local/bin/gdal-config \
--with-gdal=/usr/local/bin/gdal-config \
--with-httpd=/usr/sbin/httpd \
--with-wfsclient \
--with-wmsclient \
--enable-debug \
--with-curl-config=/usr/bin/curl-config \
--with-proj=/usr/local \
--with-tiff \
--with-gd=/usr/local \
--with-jpeg \
--with-freetype=/usr/include \
--with-threads \
--with-wcs \
--with-xml2-config=/usr/bin/xml2-config \
--with-postgis=/usr/local/pgsql/bin/pg_config \
--with-geos=/usr/local/bin/geos-config \
--with-sos \
--with-agg \
--with-agg=/usr/local
# make
# make install
# cp -p /opt/mapserver-6.0.2/mapserv /var/www/html/cgi-bin
# ./mapserv -v
MapServer version 6.0.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
Browser Check (Assuming httpd Installed)
---------------------------------------------------
http://localhost/cgi-bin/mapserv
No query information to decode. QUERY_STRING is set, but empty.
Tune Postgres
-------------
# vi /usr/local/pgsql/data/postgresql.conf
shared_buffers = 128MB
checkpoint_segments = 20
maintenance_work_mem = 256MB
autovacuum = off
# sysctl -w kernel.shmmax=268435456
# sysctl -p /etc/sysctl.conf
Create gis Database
-------------------
# su - postgres
$ pg_ctl stop
$ pg_ctl start
$ createuser gisuser
Shall the new role be a superuser? (y/n) y
$ createdb -E UTF8 -O gisuser gis
$ createlang plpgsql gis
$ psql -d gis -f /usr/local/pgsql/share/contrib/postgis-2.0/postgis.sql
$ psql -d gis -f /usr/local/pgsql/share/contrib/postgis-2.0/spatial_ref_sys.sql
$ echo "ALTER TABLE geometry_columns OWNER TO gisuser; ALTER TABLE spatial_ref_sys OWNER TO gisuser;" | psql -d gis
As root Install the hstore Extension in PostgreSQL
------------------------------------------
# cd /opt/postgresql-9.1.3/contrib/hstore
# make
# make install
Login to gis
------------
su - postgres
$ psql -U gisuser -d gis
Create the hstore Extension
---------------------------
gis=# create extension hstore;
As postgres Get the Following SQL Script
----------------------------------------
$ wget http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/900913.sql
Otherwise you may get the following error when trying to use osm2pgsql:
Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
failed: ERROR: AddGeometryColumns() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('','', $1 , $2 , $3 ,
$4 , $5
)"
PL/pgSQL function "addgeometrycolumn" line 4 at SQL statement
Execute the 900913.sql File
---------------------------
$ psql -U gisuser -d gis
gis=# \i 900913.sql
Download and Build osmconvert
-----------------------------
$ wget -O - http://m.m.i24.cc/osmconvert.c | cc -x c - -lz -O3 -o osmconvert
$ cp -p osmconvert /usr/bin
As root Install osm2pgsql
------------------------
# yum install osm2pgsql
-OR-
As root Build from Source
------------------------
As root Download osm2pgsql Dependencies
---------------------------------------
yum install geos-devel proj-devel postgresql-devel libxml2-devel bzip2-devel
yum install gcc-c++ protobuf-c-devel autoconf automake libtool
As root Get the osm2pgsql Source
---------------------------------
svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
As root Compile
---------------
# cd osm2pgsql/
# ./autogen.sh
# ./configure
# make
# make install
As postgres Download OSM Data
-----------------
$ http://download.geofabrik.de/osm/north-america/us/
Download virginia.osm.pbf
$ cd /opt/osmdata
As postgres Convert PBF File
----------------
$ osmconvert virginia.osm.pbf -o=virginia.osm
Go to the Location of the OSM file
----------------------------------
$ cd /opt/osmdata
To Load the OSM File, Run the Following Command as postgres User
----------------------------------------------------------------
$ osm2pgsql virginia.osm -d gis -U gisuser -P 5432 -S default.style --hstore
osm2pgsql SVN version 0.81.0 (64bit id space)
Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
NOTICE: table "planet_osm_point" does not exist, skipping
NOTICE: table "planet_osm_point_tmp" does not exist, skipping
Setting up table: planet_osm_line
NOTICE: table "planet_osm_line" does not exist, skipping
NOTICE: table "planet_osm_line_tmp" does not exist, skipping
Setting up table: planet_osm_polygon
NOTICE: table "planet_osm_polygon" does not exist, skipping
NOTICE: table "planet_osm_polygon_tmp" does not exist, skipping
Setting up table: planet_osm_roads
NOTICE: table "planet_osm_roads" does not exist, skipping
NOTICE: table "planet_osm_roads_tmp" does not exist, skipping
Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=800MB, maxblocks=102401*8192, allocation method=3
Mid: Ram, scale=100
Reading in file: virginia.osm
Processing: Node(19989k 96.1k/s) Way(878k 2.13k/s) Relation(2904 726.00/s) parse time: 624s
Node stats: total(19989248), max(1729148313) in 208s
Way stats: total(878386), max(160964728) in 412s
Relation stats: total(2904), max(2150806) in 4s
Committing transaction for planet_osm_point
Committing transaction for planet_osm_line
Committing transaction for planet_osm_polygon
Committing transaction for planet_osm_roads
Writing way (878k)
Committing transaction for planet_osm_point
Committing transaction for planet_osm_line
Committing transaction for planet_osm_polygon
Committing transaction for planet_osm_roads
Writing relation (2903)
node cache: stored: 19989248(100.00%), storage efficiency: 72.45% (dense blocks: 18839, sparse nodes: 4149815), hit rate: 100.00%
Sorting data and creating indexes for planet_osm_polygon
Sorting data and creating indexes for planet_osm_point
Sorting data and creating indexes for planet_osm_roads
Sorting data and creating indexes for planet_osm_line
Analyzing planet_osm_point finished
Analyzing planet_osm_polygon finished
Analyzing planet_osm_roads finished
Copying planet_osm_roads to cluster by geometry finished
Analyzing planet_osm_line finished
Creating indexes on planet_osm_roads finished
All indexes on planet_osm_roads created in 16s
Completed planet_osm_roads
Copying planet_osm_point to cluster by geometry finished
Copying planet_osm_polygon to cluster by geometry finished
Creating indexes on planet_osm_polygon finished
Creating indexes on planet_osm_point finished
All indexes on planet_osm_point created in 23s
Completed planet_osm_point
All indexes on planet_osm_polygon created in 23s
Completed planet_osm_polygon
Copying planet_osm_line to cluster by geometry finished
Creating indexes on planet_osm_line finished
All indexes on planet_osm_line created in 118s
Completed planet_osm_line
Osm2pgsql took 840s overall