Difference between revisions of "How to Setup an Open Street Map Tile Server under Ubuntu 18.04 in a Proxmox Container"

From steamWiki
Jump to: navigation, search
Line 33: Line 33:
 
#*You're going to see lots of Warnings.  [https://github.com/gravitystorm/openstreetmap-carto/issues/3183 this is ok].  Your tile server will work fine.
 
#*You're going to see lots of Warnings.  [https://github.com/gravitystorm/openstreetmap-carto/issues/3183 this is ok].  Your tile server will work fine.
 
##Run ''exit''
 
##Run ''exit''
 
+
#Run ''sudo nano /etc/renderd.conf'' and set the following
 
+
/nowiki>[renderd]
=CONTENT BELOW NEEDS TO BE FORMATTED=
+
set "num_threads=4" #set to the number of CPU Core's you have.  This can be found under the Resources section of your Promox Container on the Proxmox web GUI
sudo nano /etc/renderd.conf
+
[mapnik]
[renderd]
+
set "plugins_dir=/usr/lib/mapnik/3.0/input"
set "num_threads=4" to the # of CPU Core's you have
+
set "font_dir=/usr/share/fonts/truetype"
[mapnik]
+
set "find_dir_recursive=true"
set "plugins_dir=/usr/lib/mapnik/3.0/input"
+
[default]
set "font_dir=/usr/share/fonts/truetype"
+
set "XML=/home/osm/openstreetmap-carto-4.21.1/style.xml"
set "find_dir_recursive=true"
+
set "HOST=YOURSERVER.COM"</nowiki>
[default]
+
#Run ''sudo nano /etc/init.d/renderd'' and set the following
set "XML=/home/osm/openstreetmap-carto-4.21.1/style.xml"
+
<nowiki>set "RUNASUSER=osm"</nowiki>
set "HOST=YOURSERVER.COM"
+
#Run ''sudo chown osm:osm /var/lib/mod_tile/ -R''
sudo nano /etc/init.d/renderd
+
#Run ''sudo systemctl daemon-reload''
set "RUNASUSER=osm"
+
#Run ''sudo systemctl restart renderd''
sudo chown osm:osm /var/lib/mod_tile/ -R
+
#Run ''sudo nano /etc/apache2/sites-available/tileserver_site.conf'' and set the following
sudo systemctl daemon-reload
+
<nowiki>set "ServeName YOURSERVER.COM"
sudo systemctl restart renderd
+
#ServerAlias a.tile.mytileserver.org b.tile.mytileserver.org c.tile.mytileserver.org</nowiki> #comment out this line</nowiki>
sudo nano /etc/apache2/sites-available/tileserver_site.conf
+
#Run ''sudo nano /var/www/osm/slippymap.html'' and set the following
set "ServeName YOURSERVER.COM"
+
<nowiki><title>MY NEW COOL TITLE!</title>
comment out "ServerAlias a.tile.mytileserver.org b.tile.mytileserver.org c.tile.mytileserver.org" by prepending with a "#"
+
var lat=MY.START_LAT
sudo nano /var/www/osm/slippymap.html
+
var long=MY.START_LONG
change "<title>" to what you want
+
var zoom=MY_PREFERRED_ZOOM_LEVEL</nowiki>
change "var lat=", "var long=", & "var zoom=" to what you want
+
#Run ''sudo rm /var/www/index.html''
sudo rm /var/www/index.html
+
#Run ''sudo nano /var/www/index.html'' and fill with
sudo nano /var/www/index.html and fill with
+
<nowiki><html>
<html>
+
<head>
<head>
+
<meta http-equiv="refresh" content="0; url=http://YOURSERVER.COM/osm/slippymap.html" />
<meta http-equiv="refresh" content="0; url=http://YOURSERVER.COM/osm/slippymap.html" />
+
</head>
</head>
+
</html></nowiki>
</html>
 
 
 
https://www.linuxbabe.com/ubuntu/openstreetmap-tile-server-ubuntu-18-04-osm
+
*''Most of basis for this How To came from https://www.linuxbabe.com/ubuntu/openstreetmap-tile-server-ubuntu-18-04-osm''
  
 
[[Category: Linux]]
 
[[Category: Linux]]

Revision as of 07:20, 4 July 2019

Open Street Map is a well know, open source (and crown sourced) alternative to the likes of Google Maps and Bing Maps. Open Street Maps content (ie: maps) are provided to users and applications by what are known as Tile Servers. This tutorial will show you how to setup an Open Street Map Tile Server of your own in a Linux Container running Ubuntu 18.04 under Proxmox. Furthermore we'll use the built in and simple Map Viewer. This means that this container can provide map tiles to other applications (such as an ADS-B Virtual Radar Server) as well as providing its own native Google Maps -like capability all while being totally disconnected from the internet.

Install Prerequisites

  1. Run sudo apt update
  2. Run sudo apt upgrade
  3. Run sudo dpkg-reconfigure locales
    • select "en_US.UTF-8 UTF-8" on both screens
  4. Run sudo apt install software-properties-common
    • hit Enter to continue
  5. Run sudo add-apt-repository ppa:osmadmins/ppa
  6. Run sudo apt install postgresql postgresql-contrib postgis postgresql-10-postgis-2.4 osm2pgsql libapache2-mod-tile renderd curl unzip gdal-bin mapnik-utils libmapnik-dev nodejs npm ttf-dejavu fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted ttf-unifont
    • choose Yes to "enable mod_tile in the apache config"
  7. Run sudo npm install -g carto
  8. Run sudo -u postgres -i
    1. Run createuser osm
    2. Run createdb -E UTF8 -O osm gis
    3. Run psql -c "CREATE EXTENSION postgis;" -d gis
    4. Run psql -c "CREATE EXTENSION hstore;" -d gis
    5. Run psql -c "ALTER TABLE spatial_ref_sys OWNER TO osm;" -d gis
    6. Run exit
  9. Run sudo adduser osm
  10. Run su - osm
    1. Run wget https://github.com/gravitystorm/openstreetmap-carto/archive/v4.21.1.tar.gz
    2. Run tar xvf v*.tar.gz
    3. Run wget -c http://download.geofabrik.de/north-america/us/georgia-latest.osm.pbf
      • This tutorial is downloading only the state of Georgia in the US
      • You can download the entire planet's PBF file here or select individual states and countries here.
    1. Run osm2pgsql --slim -d gis --hstore --multi-geometry --number-processes 2 --tag-transform-script /home/osm/openstreetmap-carto-4.21.1/openstreetmap-carto.lua --style /home/osm/openstreetmap-carto-4.21.1/openstreetmap-carto.style -C 3072 /home/osm/georgia-latest.osm.pbf
    2. Run cd /home/osm/openstreetmap-carto-4.21.1
    3. Run scripts/get-shapefiles.py
    4. Run carto project.mml > style.xml
    • You're going to see lots of Warnings. this is ok. Your tile server will work fine.
    1. Run exit
  11. Run sudo nano /etc/renderd.conf and set the following
/nowiki>[renderd]

set "num_threads=4" #set to the number of CPU Core's you have. This can be found under the Resources section of your Promox Container on the Proxmox web GUI [mapnik] set "plugins_dir=/usr/lib/mapnik/3.0/input" set "font_dir=/usr/share/fonts/truetype" set "find_dir_recursive=true" [default] set "XML=/home/osm/openstreetmap-carto-4.21.1/style.xml" set "HOST=YOURSERVER.COM"</nowiki>

  1. Run sudo nano /etc/init.d/renderd and set the following
set "RUNASUSER=osm"
  1. Run sudo chown osm:osm /var/lib/mod_tile/ -R
  2. Run sudo systemctl daemon-reload
  3. Run sudo systemctl restart renderd
  4. Run sudo nano /etc/apache2/sites-available/tileserver_site.conf and set the following
set "ServeName YOURSERVER.COM"
#ServerAlias a.tile.mytileserver.org b.tile.mytileserver.org c.tile.mytileserver.org #comment out this line</nowiki>
  1. Run sudo nano /var/www/osm/slippymap.html and set the following
<title>MY NEW COOL TITLE!</title>
var lat=MY.START_LAT
var long=MY.START_LONG
var zoom=MY_PREFERRED_ZOOM_LEVEL
  1. Run sudo rm /var/www/index.html
  2. Run sudo nano /var/www/index.html and fill with
<html>
	<head>
		<meta http-equiv="refresh" content="0; url=http://YOURSERVER.COM/osm/slippymap.html" />
	</head>
</html>