Last active
June 7, 2017 00:46
-
-
Save Synashida/193eb3fc2e2f5107d73d3bdc79d09710 to your computer and use it in GitHub Desktop.
OpenStreetMapのタイルサーバを構築する (CentOS7) ref: http://qiita.com/Syn256/items/633aef930455bfd4be0d
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
#[base]の最後に行追加 | |
exclude=postgresql* | |
#[updates]の最後に行追加 | |
exclude=postgresql* | |
#[extras]の最後に行追加 | |
exclude=postgresql* |
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
#SELINUX=enforcing | |
SELINUX=disabled |
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
# 再起動する | |
reboot | |
getenforce | |
Disabledになっていることを確認 |
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
cd ~ | |
wget http://download.geofabrik.de/asia/japan/kanto-latest.osm.bz2 | |
# cacheはMB単位です。実メモリの75%くらいまでは指定しても大丈夫だと思います。 | |
osm2pgsql -m -d gis kanto-latest.osm.bz2 -U postgres --cache 6000 |
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
yum -y install gdal-python gdal-devel icu libicu libicu-devel | |
yum -y install python-pip | |
pip install --upgrade pip | |
cd /usr/local/src | |
# v2.0系 | |
wget https://github.com/downloads/mapnik/mapnik/mapnik-v2.0.2.tar.bz2 | |
tar -jxvf mapnik-v2.0.2.tar.bz2 | |
cd mapnik-v2.0.2 | |
python scons/scons.py PG_CONFIG=/usr/pgsql-9.6/bin/pg_config | |
make install | |
ldconfig | |
ldconfig -v | |
ln -s /usr/local/lib64/libmapnik.so.2.0 /usr/lib64/libmapnik.so.2.0 | |
cd /usr/local/src/mapnik-v2.0.2 | |
git clone https://github.com/openstreetmap/mapnik-stylesheets.git | |
cd mapnik-stylesheets | |
wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz | |
wget http://tile.openstreetmap.org/processed_p.tar.bz2 | |
wget http://tile.openstreetmap.org/shoreline_300.tar.bz2 | |
tar xzf world_boundaries-spherical.tgz | |
tar xjf processed_p.tar.bz2 -C world_boundaries | |
tar xjf shoreline_300.tar.bz2 -C world_boundaries | |
cd world_boundaries | |
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip | |
wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip | |
unzip ne_10m_populated_places.zip | |
unzip ne_110m_admin_0_boundary_lines_land.zip | |
cd ../../mapnik-stylesheets | |
./generate_xml.py --host localhost --user postgres --dbname gis --symbols ./symbols/ --world_boundaries=./world_boundaries/ --accept-none |
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
yum -y install httpd httpd-devel |
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
mkdir -p /var/run/renderd | |
mkdir -p /var/lib/mod_tile | |
chmod 777 /var/run/renderd | |
chmod 777 /var/lib/mod_tile | |
vi /etc/renderd.conf |
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
cd /usr/local/src | |
git clone https://github.com/openstreetmap/mod_tile.git | |
cd mod_tile | |
./autogen.sh | |
./configure --with-apxs=/usr/bin/apxs | |
make | |
make install | |
make install-mod_tile | |
ldconfig |
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
vi /etc/httpd/conf/httpd.conf | |
# Include conf.modules.d/*.confの直下あたりに追記 | |
LoadModule tile_module modules/mod_tile.so | |
LoadTileConfigFile /etc/renderd.conf | |
ModTileRenderdSocketName /var/run/renderd/renderd.sock | |
ModTileRequestTimeout 30 | |
ModTileMissingRequestTimeout 30 |
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
cd /var/www/html | |
vi index.html |
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
systemctl disabled firewalld | |
systemctl stop firewalld | |
systemctl enable httpd | |
systemctl start httpd | |
/usr/local/bin/renderd -f > /var/log/renderd.log 2> /var/log/renderd.log & |
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
systemctl disabled firewalld | |
systemctl stop firewalld | |
systemctl enable httpd | |
systemctl start httpd | |
/usr/local/bin/renderd -f > /var/log/renderd.log 2> /var/log/renderd.log & |
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
yum -y upgrade | |
yum -y install epel-release | |
yum -y install wget git freetype-devel libxml2-devel bzip2-devel freetype-devel libtool-ltdl-devel libpng-devel libtiff-devel libjpeg-devel gcc-c++ bzip2 bzip2-devel libcurl-devel libpng-devel libtiff-devel libtool-ltdl-devel pycairo-devel cairomm-devel libjpeg-turbo-devel zip unzip libtool autoconf automake | |
vi /etc/yum.repos.d/CentOS-Base.repo |
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
cd /usr/local/src | |
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm | |
rpm -ivh pgdg-centos96-9.6-3.noarch.rpm | |
yum -y install postgresql96 postgresql96-contrib postgresql96-devel postgresql96-libs postgresql96-server | |
/usr/pgsql-9.6/bin/postgresql96-setup initdb | |
systemctl start postgresql-9.6 | |
systemctl enable postgresql-9.6 | |
vi /var/lib/pgsql/9.6/data/pg_hba.conf |
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
systemctl restart postgresql-9.6 | |
psql -Upostgres |
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
yum -y install postgis2_96 postgis2_96-client postgis2_96-devel postgis2_96-utils ogr_fdw96 pgrouting_96 |
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
yum -y install cmake libpqxx libpqxx-devel boost boost-devel proj proj-devel proj-epsg lua lua-devel geos-devel protobuf-c protobuf-c-devel | |
cd /usr/local/src | |
git clone https://github.com/openstreetmap/osm2pgsql | |
cd osm2pgsql | |
mkdir build && cd build | |
cmake .. | |
make | |
make install | |
ldconfig |
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
su postgres | |
createdb template_postgis | |
psql -d template_postgis -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis'" | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/postgis.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/spatial_ref_sys.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/postgis_comments.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/rtpostgis.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/raster_comments.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/topology.sql | |
psql -d template_postgis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/topology_comments.sql | |
createdb gis | |
psql -d gis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/postgis.sql | |
psql -d gis -f /usr/pgsql-9.6/share/contrib/postgis-2.3/spatial_ref_sys.sql |
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
<html> | |
<head> | |
<title>OpenLayers Demo</title> | |
<style type="text/css"> | |
html, body, #basicMap { | |
width: 100%; | |
height: 100%; | |
margin: 0; | |
} | |
</style> | |
<script src="http://www.openlayers.org/api/OpenLayers.js"></script> | |
<script> | |
function init() { | |
var options = { | |
projection: new OpenLayers.Projection("EPSG:900913"), | |
displayProjection: new OpenLayers.Projection("EPSG:4326"), | |
units: "m", | |
maxResolution: 156543.0339, | |
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, | |
20037508.34, 20037508.34), | |
numZoomLevels: 20, | |
controls: [ | |
new OpenLayers.Control.Navigation(), | |
new OpenLayers.Control.PanZoomBar(), | |
new OpenLayers.Control.Permalink(), | |
new OpenLayers.Control.ScaleLine(), | |
new OpenLayers.Control.MousePosition(), | |
new OpenLayers.Control.KeyboardDefaults() | |
] | |
}; | |
map = new OpenLayers.Map("basicMap",options); | |
var newL = new OpenLayers.Layer.OSM("Default", "/osm_tiles2/${z}/${x}/${y}.png", {numZoomLevels: 19}); | |
map.addLayer(newL); | |
map.zoomIn(); | |
} | |
</script> | |
</head> | |
<body onload="init();"> | |
<div id="basicMap"></div> | |
</body> | |
</html> | |
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
# peerをtrustに(開発用) | |
local all all trust | |
host all all 127.0.0.1/32 trust | |
host all all ::1/128 trust |
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
[renderd] | |
socketname=/var/run/renderd/renderd.sock | |
num_threads=8 | |
tile_dir=/var/lib/mod_tile | |
stats_file=/var/run/renderd/renderd.stats | |
[mapnik] | |
plugins_dir=/usr/local/lib64/mapnik/input | |
font_dir=/usr/local/lib64/mapnik/fonts | |
font_dir_recurse=1 | |
[default] | |
URI=/osm_tiles2/ | |
XML=/usr/local/src/mapnik-stylesheets/osm.xml # mapnik-style内のosm.xmlを指定 | |
HOST=localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment