1,575
edits
Changes
no edit summary
=Install Prerequisites=
#Run Log into your machine as a ''sudo apt update''capable user#Run ''Make sure your system is up to date by running <pre>sudo apt update sudo apt upgrade''</pre>#Run ''Ensure your locale is set to UTF-8 by running <pre>sudo dpkg-reconfigure locales</pre> and selecting '''#*select "en_US.UTF-8 UTF-8" ''' on both screens#Run ''Install the Open Street Map repository by running <pre>sudo apt install software-properties-common''&#*hit '''Enter''' to continue#Run ''10;sudo add-apt-repository ppa:osmadmins/ppa''</pre>#Run 'Install the packages we'll need by running <pre>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''</pre>#*When prompted, choose '''Yes''' to "enable mod_tile in the apache config"#Run ''Install the node.js Mapnik Stylesheet Compiler by running <pre>sudo npm install -g carto''</pre>#Run ''Setup our database by running <pre>sudo -u postgres -i''##Run ''</pre> and then from within the postgres prompt running <pre>createuser osm''&##Run ''10;createdb -E UTF8 -O osm gis''&##Run ''10;psql -c "CREATE EXTENSION postgis;" -d gis''&##Run ''10;psql -c "CREATE EXTENSION hstore;" -d gis''&##Run ''10;psql -c "ALTER TABLE spatial_ref_sys OWNER TO osm;" -d gis''&##Run ''10;exit''</pre>#Run ''Create our Tile Server user and get into his home directory by running <pre>sudo adduser osm''&#Run ''10;su - osm''</pre>##Run ''Download a generic OSM mapnik style by running <pre>wget https://github.com/gravitystorm/openstreetmap-carto/archive/v4.21.1.tar.gz''</pre>##Run ''Uncompress the style by running <pre>tar xvf v*.tar.gz''</pre>##Run ''Download a PBF map file by running <pre>wget -c http://download.geofabrik.de/north-america/us/georgia-latest.osm.pbf''</pre>
##*This tutorial is downloading only the state of Georgia in the US
##*You can download the entire planet's PBF file [http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf here] or select individual states and countries [http://download.geofabrik.de here].
#*At this point the [https://www.linuxbabe.com/ubuntu/openstreetmap-tile-server-ubuntu-18-04-osm standard Ubuntu 18.04 setup guide] I followed had you configure your machine's swap. Since Proxmox handles this we'll skip that step
##Run ''Import your PBF file by running <pre>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''</pre>##Run ''Move into the carto directory by running <pre>cd /home/osm/openstreetmap-carto-4.21.1''</pre>##Run ''Get shapefiles by running <pre>scripts/get-shapefiles.py''</pre>##Run ''Build your Mapnik xml stylesheet by running <pre>carto project.mml > style.xml''</pre>
#*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 Get back to your ''exitsudo''user by running <pre>exit</pre>#Run ''Modify the renderd config file by running <pre>sudo nano /etc/renderd.conf'' </pre> and set setting the following /nowikivariables <pre>[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"</nowikipre>#Run 'Edit renderd's daemon script by running <pre>sudo nano /etc/init.d/renderd'' </pre> and set setting the following <nowikipre>set "RUNASUSER=osm"</nowikipre>#Run Make ''osm'' the owner of the ''mod_tile'' library by running <pre>sudo chown osm:osm /var/lib/mod_tile/ -R''</pre>#Run ''Reload the daemon scripts by running <pre>sudo systemctl daemon-reload</pre>#Restart renderd with the new ''#Run osm''user by running <pre>sudo systemctl restart renderd''</pre>#Run 'Edit Apache's tile server configuration by running <pre>sudo nano /etc/apache2/sites-available/tileserver_site.conf'' </pre> and set setting the following variables <nowikipre>set "ServeName YOURSERVER.COM" #ServerAlias a.tile.mytileserver.org b.tile.mytileserver.org c.tile.mytileserver.org</nowiki> #comment out this line</nowikipre>#Run ''Modify the slippymap.html page by running <pre>sudo nano /var/www/osm/slippymap.html'' </pre> and set setting the following <nowikipre><title>MY NEW COOL TITLE!</title> var lat=MY.START_LAT var long=MY.START_LONG var zoom=MY_PREFERRED_ZOOM_LEVEL</nowikipre>#Run 'Delete Apache's default landing page by running <pre>sudo rm /var/www/index.html''</pre>#Run ''Create a new redirect page so that when people visit http://YOURSERVER.COM they get to the interactive slippymap page by running <pre>sudo nano /var/www/index.html'' </pre> and fill filling in the file with <nowikipre><html> <head> <meta http-equiv="refresh" content="0; url=http://YOURSERVER.COM/osm/slippymap.html" /> </head> </html></nowikipre>
*''Most of basis for this How To came from https://www.linuxbabe.com/ubuntu/openstreetmap-tile-server-ubuntu-18-04-osm''
[[Category: Linux]]