OSM tileserver on a vanilla Ubuntu 16.04 droplet

adduser osm
usermod -aG sudo osm
su osm
sudo mkdir ~/.ssh
sudo nano ~/.ssh/authorized_keys
sudo apt update sudo apt upgrade
sudo apt install curl unzip autoconf gdal-bin libtool
sudo apt install postgresql postgresql-contrib postgis postgresql-9.5-postgis-2.2
sudo -u postgres -i
postgres$ psql
postgres$ createuser osm
postgres$ createdb -E UTF8 -O osm england
postgres$ psql -c "CREATE EXTENSION hstore;" -d england
postgres$ psql -c "CREATE EXTENSION postgis;" -d england
postgres$ exit
mkdir ~/osm_data
wget http://download.geofabrik.de/europe/great-britain/england-latest.osm.pbf -O ~/osm_data/england.pbf
sudo apt install osm2pgsql
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo nano /etc/ssh/ssh_config
Host *

ClientAliveInterval 30 TCP

KeepAlive yes

ClientAliveCountMax 99999
sudo service sshd restart
mkdir ~/osm_styles
cd ~/osm_styles
git clone https://github.com/gravitystorm/openstreetmap-carto ~/osm_styles/openstreetmap-carto
osm2pgsql --slim -d england -C 3600 --hstore -S ~/osm_styles/openstreetmap-carto/openstreetmap-carto.style ~/osm_data/england.pbf
sudo apt install node-carto libmapnik3.0 libmapnik-dev mapnik-utils python-mapnik apache2 apache2-dev
git clone https://github.com/openstreetmap/mod_tile.git
cd mod_tile/
sudo make install
sudo make install-mod_tile
cd ~/osm_styles/openstreetmap-carto
nano project.mml
carto project.mml > style.xml
sudo nano /usr/local/etc/renderd.conf




sudo cp ~/mod_tile/debian/renderd.init /etc/init.d/renderd
sudo chmod a+x /etc/init.d/renderd
sudo nano /etc/init.d/renderd

DAEMON_ARGS="-c /usr/local/etc/renderd.conf"

sudo mkdir -p /var/lib/mod_tile
sudo chown osm:osm /var/lib/mod_tile
sudo systemctl daemon-reload
sudo service renderd start
sudo service renderd enabled
sudo nano /etc/apache2/mods-available/mod_tile.load
LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so
sudo ln -s /etc/apache2/mods-available/mod_tile.load /etc/apache2/mods-enabled/
sudo nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
LoadTileConfigFile /usr/local/etc/renderd.conf
ModTileRenderdSocketName /var/run/renderd/renderd.sock
ModTileRequestTimeout 0
ModTileMissingRequestTimeout 30
Header set Access-Control-Allow-Origin "*"
sudo service apache2 restart
sudo service renderd restart



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dennis Bauszus

Dennis Bauszus

I am doing some web and map stuff with @GEOLYTIX. Mostly maps on the web.