Differences between revisions 2 and 12 (spanning 10 versions)
Revision 2 as of 2019-10-09 00:28:16
Size: 3332
Editor: PaulWise
Comment: incorrectly named
Revision 12 as of 2020-11-21 20:16:04
Size: 4811
Comment: test after installation part added
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
1. Login as root and install the following packages:

{{{
apt install postgresql postgis apache2 apache2-dev libmapnik-dev osm2pgsql python-mapnik git mapnik-utils fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont
}}}

2. Create user account:

adduser gisuser

3. Prepare database.
Database will be called gis and owned bu user gisuser
Table of contents:
<<TableOfContents()>>

===
1. Install required packages ===

Login as root, and run:

{{{
apt install postgresql postgis apache2 apache2-dev libmapnik-dev osm2pgsql python-mapnik git mapnik-utils fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont python3-psycopg2 python3-yaml gdal-bin
}}}

===
2. Create user account ===

{{{
useradd -m gisuser
}}}

===
3. Prepare database ===

Create database user '''gisuser''' and database '''gis''':
Line 25: Line 33:
create user gis; create user gisuser;
Line 40: Line 48:
4. Build renderd === 4. Build renderd ===
Line 51: Line 60:
debian/compat: `debian/compat`:
Line 55: Line 64:
debian/changelog:

 change version in first line from: 0.4-12~precise2 to 0.4.12~buster. If the version will be different, change it accoringly: Version number can't containg '-' character.
`debian/changelog`:

 change version in first line from: 0.4-12~precise2 to 0.4.12~buster. If the version will be different, change it accordingly: Version number can't contain the '-' character.
Line 62: Line 72:
debian/renderd.init

  change the following variables:
`debian/renderd.init`:

Change the following variables:
Line 71: Line 82:
In ~/src/mod_tile directory, issue:
{{{
Finally build package:

{{{
cd ~/src/mod_tile
Line 78: Line 91:
Line 82: Line 96:
{{{
dpkg -i libapache2-mod-tile_0.4.12~buster_amd64.deb renderd_0.4.12~buster_amd64.deb
}}}

5. Download and build opencarto

{{{
apt install ./libapache2-mod-tile_0.4.12~buster_amd64.deb ./renderd_0.4.12~buster_amd64.deb
}}}

=== 5. Download and build opencarto ===
Line 89: Line 105:
npm install -g carto npm install carto
Line 96: Line 112:
After last command, you can see a lot of warnings. I don't understand them, but it looks they they are irrelevant :)

6. Download map data

If carto fails with: no such file, try from root:

{{{
cd /home/gisuser/openstreetmap-carto
/root/node_modules/carto/bin/carto project.mml > mapnik.xml
}}}

After last command, you can see a lot of warnings. I don't understand them, but it looks that they are irrelevant :)

=== 6. Download map data ===
Line 100: Line 125:
Line 103: Line 129:
wget https://download.geofabrik.de/your_country.osm.pbf
}}}
For testing you can download some small pbf file, i.e.: https://download.geofabrik.de/africa/cape-verde-latest.osm.pbf

7. Import map to gis database:
wget https://download.geofabrik.de/<interesting area>.osm.pbf
}}}

For testing you can download a small pbf file, i.e.: https://download.geofabrik.de/africa/cape-verde-latest.osm.pbf

=== 7. Import map to gis database ===
Line 109: Line 137:
Line 112: Line 141:
Of course, instead of cape-verde-latest.osm.pbf, you can use any pbf you want.

8. Load shape files:

Of course, instead of `cape-verde-latest.osm.pbf`, you can use any pbf you want.

=== 8. Load shape files ===
Line 117: Line 148:
scripts/get-shapefiles.py
}}}

9. Fix renderd path to
scripts/get-external-data.py
}}}

If it fails with:
{{{
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip
}}}

change url in external-data-yml from:
{{{
url: https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip
}}}
to:
{{{
url: https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip
}}}

and run again:
{{{
scripts/get-external-data.py
}}}


=== 9. Fix renderd paths ===
Line 123: Line 174:
Line 132: Line 184:
10. Fix mod_tile permitions === 10. Fix mod_tile permissions ===
Line 134: Line 187:
Line 138: Line 192:
11. Finally restart renderd

{{{
/etc/init.d/renderd stop
/etc/init.d/renderd start
}}}
=== 11. Finally start renderd ===

{{{
service renderd stop
service renderd start
}}}
Line 145: Line 200:

=== 12. Test installation ===

You will find /etc/renderd.conf
{{{
URI=/osm/
}}}

You can test after restarting apache
{{{
http://localhost/osm/0/0/0.png
}}}

edit /var/www/osm/slippymap.html
{{{
// This is the layer that uses the locally stored tiles
var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "http://YOUR_IP_ADDRESS/osm/${z}/${x}/${y}.png", {numZoomLevels: 19});
}}}

Test local data:
{{{
http://YOUR_IP_ADDRESS/osm/slippymap.html
}}}

This guide will help to install OSM Tile server on Debian Buster

OSM database: gis

Database user: gisuser

Table of contents:

1. Install required packages

Login as root, and run:

apt install postgresql postgis apache2 apache2-dev libmapnik-dev osm2pgsql python-mapnik git mapnik-utils fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont python3-psycopg2 python3-yaml gdal-bin

2. Create user account

useradd -m gisuser

3. Prepare database

Create database user gisuser and database gis:

su - postgres
psql

create user gisuser;
create database gis owner gisuser;
\q

psql gis

CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
ALTER TABLE geometry_columns OWNER TO gisuser;
ALTER TABLE spatial_ref_sys OWNER TO gisuser;
\q

exit

4. Build renderd

su - gisuser
mkdir ~/src
cd ~/src
git clone -b switch2osm https://github.com/SomeoneElseOSM/mod_tile.git
cd mod_tile

Modify the following files:

debian/compat:

  • change 7 -> 9

debian/changelog:

  • change version in first line from: 0.4-12~precise2 to 0.4.12~buster. If the version will be different, change it accordingly: Version number can't contain the '-' character.

libapache2-mod-tile (0.4.12~buster) precise; urgency=low

debian/renderd.init:

Change the following variables:

DAEMON=/usr/bin/$NAME
DAEMON_ARGS="-c /etc/renderd.conf"
RUNASUSER=gisuser

Finally build package:

cd ~/src/mod_tile
./autogen.sh
dpkg-buildpackage -uc -us

In ~/src directory you should find:

libapache2-mod-tile_0.4.12~buster_amd64.deb renderd_0.4.12~buster_amd64.deb

Install them from root account:

apt install ./libapache2-mod-tile_0.4.12~buster_amd64.deb ./renderd_0.4.12~buster_amd64.deb

5. Download and build opencarto

apt install npm nodejs
npm install carto
su - gisuser
cd ~/src
git clone git://github.com/gravitystorm/openstreetmap-carto.git
cd openstreetmap-carto
carto project.mml > mapnik.xml

If carto fails with: no such file, try from root:

cd /home/gisuser/openstreetmap-carto
/root/node_modules/carto/bin/carto project.mml > mapnik.xml

After last command, you can see a lot of warnings. I don't understand them, but it looks that they are irrelevant :)

6. Download map data

Under gisuser account:

mkdir ~/data
cd ~/data
wget https://download.geofabrik.de/<interesting area>.osm.pbf

For testing you can download a small pbf file, i.e.: https://download.geofabrik.de/africa/cape-verde-latest.osm.pbf

7. Import map to gis database

Under gisuser account:

osm2pgsql -d gis --create --slim  -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2500 --number-processes 1 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ~/data/cape-verde-latest.osm.pbf

Of course, instead of cape-verde-latest.osm.pbf, you can use any pbf you want.

8. Load shape files

cd ~/src/openstreetmap-carto
scripts/get-external-data.py

If it fails with:

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip

change url in external-data-yml from:

url: https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip

to:

url: https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip

and run again:

scripts/get-external-data.py

9. Fix renderd paths

In /etc/renderd.conf you should have:

[mapnik]
plugins_dir=/usr/lib/mapnik/3.0/input
font_dir=/usr/share/fonts/truetype/dejavu

[default]
XML=/home/gisuser/src/openstreetmap-carto/mapnik.xml

10. Fix mod_tile permissions

From root:

chown gisuser.gisuser /var/lib/mod_tile

11. Finally start renderd

service renderd stop
service renderd start

check /var/log/syslog for messages from renderd.

12. Test installation

You will find /etc/renderd.conf

URI=/osm/

You can test after restarting apache

http://localhost/osm/0/0/0.png

edit /var/www/osm/slippymap.html

// This is the layer that uses the locally stored tiles
var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "http://YOUR_IP_ADDRESS/osm/${z}/${x}/${y}.png", {numZoomLevels: 19});

Test local data:

http://YOUR_IP_ADDRESS/osm/slippymap.html