MARCO's FREE MEMO

携帯フォトや備忘録などをちょこっと…

Mapserver インストール

2012年09月29日 14時29分25秒 | JavaScript
先週、ノートPCを買い換えた。
Core i5でメモリが4GB(あと4GB買い足した)でWindows7(64bit)
「これからはVMだろう」ということでVM Player5を入れてそこにCentOSをゲストOSで入れてみた。
丁度、仕事でMapServerを扱うようになったので、まずMapServerのインストールに挑戦。

以下、あちこちのサイトを見ながら試行錯誤しながら構築したメモ
多くの人がノウハウを残してくれるからインストールであまり苦しまなくなった
皆さんに感謝☆
------------------------------------------------------------------------
■Apachの追加インストール
# yum -y install httpd httpd-devel

■PHPの追加インストール
# yum -y install php php-mbstring php-mcrypt php-pgsql php-devel php-gd

■GDのインストール
# yum -y install gd gd-devel

■GIF,PNG,JPEGのインストール
# yum -y install giflib giflib-devel
# yum -y install libpng libpng-devel
# yum -y install libjpeg libjpeg-devel

■LIbicuのインストール
# yum -y install libicu libicu-devel

■Xercesのインストール
# wget http://ftp.riken.jp/net/apache//xerces/c/3/sources/xerces-c-3.1.1.tar.gz
# tar zxvf xerces-c-3.1.1.tar.gz
# cd xerces-c-3.1.1
# ./configure --prefix=/usr/local/
# make
# make install
# /sbin/ldconfig -v

■geosのインストール
# wget http://download.osgeo.org/geos/geos-3.2.2.tar.bz2
# tar jxvf geos-3.2.2.tar.bz2
# cd geos-3.2.2
# ./configure --prefix=/usr/local/
# make
# make install
# /sbin/ldconfig -v

■PROJのインストール
# wget http://download.osgeo.org/proj/proj-4.7.0.tar.gz
# tar zxvf proj-4.7.0.tar.gz
# cd proj-4.7.0
# ./configure --prefix=/usr/local/
# make
# make install
#

■PostgreSQLのインストール
# yum -y install postgresql84 postgresql84-server postgresql84-libs postgresql84-devel

■初期設定
# service postgresql initdb

■起動
# service postgresql start

■PostGISをインストール
# wget http://postgis.refractions.net/download/postgis-1.5.3.tar.gz
# tar zxvf postgis-1.5.3.tar.gz
# cd postgis-1.5.3
# ./configure \
--with-geos=/usr/local/bin/geos-config \
--with-pgconfig=/usr/bin/pg_config \
--with-proj=/usr/local \
--with-proj-libdir=/usr/local/lib
# make
# make install

■GDAL/OGRをインストール
// 追加パッケージを導入 (導入済であれば不要)
# yum -y install curl curl-devel unixODBC unixODBC-devel

# wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
# tar zxvf gdal-1.9.0.tar.gz
# cd gdal-1.9.0
# ./configure \
--with-libtiff=internal \
--with-pg \
--with-pymoddir=/usr/lib/python2.4/site-packages \
--with-python \
--with-xerces=/usr/local/ \
--with-odbc \
--with-geos=/usr/local/bin/geos-config
# make
# make install

■MapServerをインストールする
// 追加パッケージを導入 (導入済ならば不要)
# yum install freetype freetype-devel

# wget http://download.osgeo.org/mapserver/mapserver-5.6.8.tar.gz
# tar zxvf mapserver-5.6.8.tar.gz
# cd mapserver-5.6.8
# ./configure \
--with-tiff \
--with-zlib \
--with-jpeg \
--with-png \
--with-freetype \
--with-gd \
--with-geos \
--with-postgis=/usr/bin/pg_config \
--with-proj \
--with-sos \
--with-threads \
--with-wcs \
--with-wfs \
--with-wfsclient \
--with-wmsclient \
--with-wmsserver \
--with-gdal=/usr/local/bin/gdal-config \
--with-ogr=/usr/local/bin/gdal-config \
--with-agg \
--with-php=/usr/include/php \
--with-httpd=/usr/sbin/httpd
# make

■makeでエラーが出たら足りないライブラリを追加
/usr/bin/ld: cannot find -lxslt
/usr/bin/ld: cannot find -lpam
# yum -y install libxslt libxslt-devel
# yum -y install pam pam-devel

// イントーラーは付属しないので、手動で設置する
# cp legend mapserv mapserver-config msencrypt scalebar shp2img shp2mysql.pl shp2pdf shptree shptreetst shptreevis sortshp tile4ms /usr/local/bin

■mapservモジュール確認
# /usr/local/bin/mapserv -v
/usr/local/bin/mapserv: error while loading shared libraries: libproj.so.0: cannot open shared object file: No such file or directory
というエラーが出た場合は、Libraryを追加
# echo '/usr/local/lib' > /etc/ld.so.conf.d/mapserver.conf
# /sbin/ldconfig -v
再度、モジュール確認
# /usr/local/bin/mapserv -v
MapServer version 5.6.5 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTSWFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS SUPPORTS=GEOS INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
とりあえずOK

mapservを/cgi-binディレクトリにコピー
# cp ./mapserv /var/www/cgi-bin/


■ブラウザで確認
http://localhost/cgi-bin/mapserv
「No query information to decode. QUERY_STRING is set, but empty」のメッセージで動いている

*ローカルPCからゲストOSにhttpがとどかなかったら
# system-config-securitylevel-tui
でfirewallの設定を無効にすればよい


■PostGISのデータベースを作成
# -su postgres
$ createdb -EUTF-8 -Upostgres template_postgis
$ createlang plpgsql template_postgis
$ psql -Upostgres -f /usr/share/pgsql/contrib/postgis-1.5/postgis.sql template_postgis
$ psql -Upostgres -f /usr/share/pgsql/contrib/postgis-1.5/spatial_ref_sys.sql template_postgis
$ createdb -EUTF-8 -Upostgres -Ttemplate_postgis mapdb


■shapeファイルをテーブルにインポートする
# shp2pgsql -s 4612 -D -i -I -W cp932 N03-12_12_120401.shp gyousei > gyousei.sql
$ psql mapdb -f gyousei.sql

■PostgreSQLに外部から接続するための設定
/var/lib/pgsql/data/postgres.confを修正
listen_addresses = '*' # what IP address(es) to listen on;

/var/lib/pgsql/data/pg_hbs.confに接続可能なセグメントを追加
local all all trust
host all all 192.168.xxx.1/32 trust
host all all 192.168.yyy.1/32 trust


最新の画像もっと見る

コメントを投稿