Giter VIP home page Giter VIP logo

osm-tiles-cache's Introduction

osm-tiles-cache

PHP-based cache for openstreetmap tiles Copyright (c) 2018 Andrew MacKinnon Copyright (c) 2014 Stefan Lemme

Released under the MIT license, see LICENSE for more information.

Requirements: A Linux server with Apache and PHP installed.

How to install:

  1. Create a directory /var/www/html/api/tiles/
  2. Copy the load.php file to /var/www/html/api/tiles/
  3. Copy the provided .htaccess file to /var/www/html/api/tiles/ and enable mod_rewrite support. This will rewrite requests for tiles like /api/tiles/osm/10/283/370.png to load.php.
  4. Create a folder /var/www/html/api/tiles/preload/. For each tile server you want to use, copy a .php.sample to name.php where name is the name of the tile server that you wish to use. Please see https://wiki.openstreetmap.org/wiki/Tile_servers for a list of tile servers. Make sure you have permission to use the tile server you wish to use. Please be advised that the Mapbox tile server service does not permit tile caching under its terms of service.
  5. Optional: There is also a preload.php which pre-downloads tiles and places them into the cache directory. If you wish, you can also copy this file to /var/www/html/api/tiles/ to enable the preloader. WARNING: ALWAYS add an entry to .htaccess that either restricts access to this file to the localhost or requires a password to view preload.php. Otherwise, a malicious user can download a large area of tiles and fill up all your disk space! Also, keep in mind that some tile providers may dislike you using preload.php because it downloads a large number of tiles and uses up a large amount of server resources.
  6. Strongly recommended:

Run sudo crontab -e and add the following line to crontab:

0 7 * * * find /var/www/html/api/tiles/cache/ -mindepth 1 -mtime +7 -delete

This deletes any tile in the tile cache directory every day at 7:00 UTC which is older than 1 week (+7). Change the directory, age and time to run the cron script as appropriate. This will prevent the tile cache directory from taking up too much disk space from old tiles which we never will use anyway.

osm-tiles-cache's People

Contributors

andrewpmk avatar stlemme avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

osm-tiles-cache's Issues

preload.php should not be publicly accessible

preload.php should not be publicly accessible because this allows a malicious user to download large numbers of tiles from OSM and fill up the entire hard disk and use a lot of network bandwidth and CPU.

Add an entry to .htaccess to deny preload.php to anyone except localhost.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.