In this tutorial, you will learn how to install TileServer PHP, an open-source tool that allows you to serve map tiles from any MBTiles-compatible tileset. We will demonstrate how to install TileServer PHP on EndeavourOS, which is an Arch Linux-based rolling-release distribution.
Before you start, make sure you have the following:
The first step is to install the packages that are required to run TileServer PHP. Run the following command to update the package list and install the required packages:
sudo pacman -Syu lighttpd php php-cgi php-gd php-curl php-zip git
After the installation of the required packages is complete, you need to clone the TileServer PHP repository from Github. Run the following command to do so:
sudo git clone https://github.com/maptiler/tileserver-php.git /var/www/html/
/var/www/html/
directory is the default web root directory in lighttpd. You can change this path according to your web server configuration.To serve a tileset in TileServer PHP, you need to create an MBTiles file. You can create an MBTiles file using MapTiler Desktop, which is a GUI tool for creating map tiles. If you don't have MapTiler Desktop, you can download it from the following link:
After creating the MBTiles file, you need to copy it to the mbtiles
directory in the TileServer PHP directory, which is located at /var/www/html/mbtiles/
. You can copy your MBTiles file there with a command like:
sudo cp /path/to/your/metadata.mbtiles /var/www/html/mbtiles/
To configure TileServer PHP, you need to create a config.json
file in the TileServer PHP directory. You can use the following command to create the file:
sudo nano /var/www/html/config.json
Then, copy and paste the following contents in the config.json
file:
{
"name": "Your Tileset Name",
"description": "Description of Your Tileset",
"template": "osm-liberty",
"source": "/mbtiles/metadata.mbtiles",
"minzoom": 0,
"maxzoom": 14,
"bounds": [
-180,
-85.0511,
180,
85.0511
]
}
Your Tileset Name
and Description of Your Tileset
with your own tileset name and description.metadata.mbtiles
with the name of the MBTiles file you copied to the mbtiles
directory.After entering the required information in the config.json
file, save it by pressing Ctrl+X
, Y
, and Enter
.
After the configuration is complete, you can access your TileServer PHP by navigating to http://localhost/tileserver-php
. You should see a map with your custom tiles displayed on it.
In this tutorial, you learned how to install TileServer PHP on EndeavourOS and serve map tiles from an MBTiles file. You also learned how to configure TileServer PHP, access the web interface and create MBTiles files using MapTiler Desktop. With the ongoing development of TileServer PHP, you have a very powerful tool at your disposal, enabling you to serve custom map tiles with ease.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!