さくらVPSでtilemill

tilemillは、スタンドアローンの地図タイル作成ソフトだと思っていたら、サーバーアプリケーション&地図タイル配信サーバーにもなるようです。(node.jsってすごいなー)
というわけで、さくらVPSにtilemillをインストールして、それを試してみます。

カスタムインストール

ubuntu12.04 amd64を選択。
こちらを参考にインストール
http://support.sakura.ad.jp/manual/vps/mainte/custom_ubuntu1204.html
https://secure.sakura.ad.jp/vpscontrol/main/

設定

こちらを参考にsshの設定
http://akabeko.me/blog/2012/04/revps-01-prepare-ssh-key/

最新状態に更新
apt-get update
apt-get upgrade
emacsのインストール

emacs派なので。

sudo apt-get install emacs

ファイアーウォールの設定

あとで書く

tilemillのインストール

こちらを参考にubuntuにtilemillをインストール
http://mapbox.com/tilemill/docs/linux-install/

このコマンドを打つだけ。

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:developmentseed/mapbox
sudo apt-get update
sudo apt-get install tilemill

tilemillの設定

こちらを参考に設定
http://mapbox.com/tilemill/docs/guides/ubuntu-service/

tilemillのUIはsshで接続したPCのみからブラウザで起動できるように。
また、タイルサーバーは公開するのでip(ドメイン)で指定。
※ここでは、仮のip 49.212.hoge.hoge

tilemill.configを編集
sudo emacs /etc/tilemill/tilemill.config

{
  "listenHost": "0.0.0.0"
  "coreUrl": "localhost:20009",
  "tileUrl": "49.212.hoge.hoge:20008",
  "server": true
}
tilemill サーバーの起動
sudo start tilemill
ローカルPCからtilemillサーバーに接続

ローカルPC(mac)のターミナルからsshで以下のように接続。(リモートのlocalhost:20009をローカルのlocalhost:20009に転送)
参考:http://www.geocities.jp/ko_tyche/linux/port.html

ssh -CA mizutani@49.212.hoge.hoge -L 20009:localhost:20009
ローカルPCのブラウザからリモートのtilemillを起動&ファイルをエクスポート

ローカルPCのブラウザを起動して、localhost:200009にアクセスするとリモートサーバー上のtilemillが起動する。
適当なプロジェクトでmbtilesをエクスポート
/usr/share/mapbox/export/ の中にmbtilesが作成される。

サーバーからmbtilesにアクセス

/usr/share/mapbox/export/の中のmbtilesは、タイルサーバーによって、49.212.hoge.hoge:20008で公開されているので、以下にアクセスして確認。
http://49.212.hoge.hoge:20008/tile/vegetation.mbtiles/1/1/1.png

コマンドでタイルを作成

tilemillの本体は以下の場所にインストールされているので、それを使ってexport

/usr/share/tilemill/node  index.js export --help


これでいつでもどこでもクラウド上で地図タイルを作成できるようになりました。;-)

PostGISのインストール

http://linfiniti.com/2012/05/installing-postgis-2-0-on-ubuntu/
http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204
http://www.finds.jp/docs/pgisman/2.0.0/postgis.html#templatepostgis

sudo apt-add-repository ppa:sharpie/for-science  # To get GEOS 3.3.2 
sudo apt-add-repository ppa:sharpie/postgis-nightly
sudo apt-get update
sudo apt-get install postgresql-9.1-postgis

sudo -u postgres createdb template_postgis
sudo -u postgres psql -d template_postgis -c "CREATE EXTENSION postgis;"
sudo -u postgres psql -d template_postgis -c "CREATE EXTENSION postgis_topology;"
sqlite3のインストール

apt-get install sqlite3

gdalのインストール

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install gdal-bin