-
Notifications
You must be signed in to change notification settings - Fork 2
Installation (Ubuntu 17.04) [ARCHIVED]
- Server with at least 4Go RAM
- Ubuntu 17.04 (obviously)
Just to be sure everything is up to date :
sudo apt update
sudo apt upgrade
And restart your server :
sudo shutdown -r now
sudo apt install cmake libboost-all-dev git-core tar unzip wget bzip2 build-essential autoconf libtool \
libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev munin-node munin libprotobuf-c-dev libxml2-dev \
protobuf-c-compiler libfreetype6-dev libpng-dev libtiff5-dev libicu-dev libgdal-dev libcairo2-dev \
libcairomm-1.0-dev apache2 apache2-dev libagg-dev ttf-unifont lua5.3 liblua5.3-dev libgeotiff-epsg \
python-yaml
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-9.6 postgresql-9.6-postgis-2.4
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt install nodejs
sudo npm install -g carto
sudo apt install fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted fonts-hanazono ttf-unifont
Warning: Replace <username>
by your username in the following command lines.
sudo -u postgres -i
createuser <username>
createdb -E UTF8 -O <username> gis
psql gis
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
ALTER TABLE geometry_columns OWNER TO <username>;
ALTER TABLE spatial_ref_sys OWNER TO <username>;
\q
exit
mkdir ~/src && cd ~/src
git clone git://github.com/openstreetmap/osm2pgsql.git
cd osm2pgsql
mkdir build && cd build
cmake ..
make
sudo make install
sudo apt install gdal-bin libmapnik-dev mapnik-utils python-mapnik
To check if Mapnik is correctly installed :
python
It'll reply with >>>
.
import mapnik
If it replies again with just >>>
- that's good \o/.
Press control-d to exit the "python" prompt.
@SomeoneElseOSM made a fork of https://github.com/openstreetmap/mod_tile so it supports Ubuntu 16.04 ; that's that fork we'll use instead of OpenStreetMap original repository.
cd ~/src
git clone git://github.com/SomeoneElseOSM/mod_tile.git
cd mod_tile
./autogen.sh
./configure
make
sudo make install
sudo make install-mod_tile
sudo ldconfig
mkdir ~/data && cd ~/data
wget http://download.geofabrik.de/europe/belgium-latest.osm.pbf
osm2pgsql --database gis --slim --cache 2500 --number-processes 2 --multi-geometry --hstore \
--style ~/openstreetmap-carto-be/openstreetmap-carto.style \
--create ~/data/belgium-latest.osm.pbf
cd ~/openstreetmap-carto-be
./scripts/get-shapefiles.py
python -c 'import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout, indent=4, separators=(",", ": "))' < project.mml > project.json.mml
carto project.json.mml > mapnik.xml
Warning: Replace <username>
by your username in the following command lines.
Create needed directories :
sudo mkdir /var/lib/mod_tile
sudo chown <username> /var/lib/mod_tile
sudo mkdir /var/run/renderd
sudo chown <username> /var/run/renderd
Create a new mod file :
sudo nano /etc/apache2/mods-available/tile.load
Add this line to tile.load
:
LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so
Create a new mod configuration file :
sudo nano /etc/apache2/mods-available/tile.conf
Add these lines to tile.conf
:
<IfModule tile_module>
LoadTileConfigFile /usr/local/etc/renderd.conf
ModTileRenderdSocketName /var/run/renderd/renderd.sock
# Timeout before giving up for a tile to be rendered
ModTileRequestTimeout 0
# Timeout before giving up for a tile to be rendered that is otherwise missing
ModTileMissingRequestTimeout 30
</IfModule>
Enable mod_tile
and restart Apache :
sudo a2enmod tile
sudo service apache2 restart
Edit renderd.conf
file :
sudo nano /usr/local/etc/renderd.conf
Set the correct number of threads : num_threads=2
Add the following lines (set the correct URI
and XML
path for each one) :
[osmbe]
URI=/osmbe/
TILEDIR=/var/lib/mod_tile
XML=/home/ubuntu/openstreetmap-carto-be/mapnik.xml
HOST=localhost
TILESIZE=256
MAXZOOM=18
CORS=*
Remove the following lines :
[ajt]
URI=/hot/
TILEDIR=/var/lib/mod_tile
XML=/home/ajtown/src/openstreetmap-carto-AJT/mapnik.xml
HOST=localhost
TILESIZE=256
MAXZOOM=20
Run renderd
in the foreground so you can check everything is running as planned :
renderd -f -c /usr/local/etc/renderd.conf
Go to http://yourserveripaddress/osmbe/0/0/0.png and if you see a map of the world everything is working great !
Press CTRL+C
to stop the foreground rendering process.
sudo cp ~/src/mod_tile/debian/renderd.init /etc/init.d/renderd
sudo chmod u+x /etc/init.d/renderd
sudo cp ~/src/mod_tile/debian/renderd.service /lib/systemd/system/
You'll need to edit renderd
to set your username in the RUNASUSER
parameter :
sudo nano /etc/init.d/renderd
Reload list of services :
sudo systemctl daemon-reload
Now you can start the new renderd
service :
sudo service renderd start
To make it start automatically every time:
sudo systemctl enable renderd
This page is based on http://wiki.openstreetmap.org/wiki/User:SomeoneElse/Ubuntu_1604_tileserver_load by @SomeoneElseOSM.