In this tutorial, we will go through the steps to install TileServer PHP from https://www.maptiler.com/server/ on Alpine Linux Latest. TileServer PHP is a lightweight and fast map tile server that can serve both raster and vector tiles.
Before you start, ensure that you have the following:
The first step is to install the required packages. We will need to install the following packages:
sudo apk update
sudo apk add curl unzip libzip-dev libpng-dev libjpeg-turbo-dev gd-dev sqlite-dev
Next, we need to download and unzip the TileServer PHP package. You can download the latest TileServer PHP package from https://www.maptiler.com/server/ and use the following commands to download and unzip it:
cd ~
curl -LO https://github.com/maptiler/tileserver-php/releases/download/v*/tileserver-php-*.zip
unzip tileserver-php-*.zip -d tileserver-php
After we have downloaded TileServer PHP, we need to install PHP and its required packages. We will install PHP 7.4 and its required packages using the following commands:
sudo apk add php7-dev php7-pear php7-gd php7-json php7-zip php7-pdo php7-pdo_sqlite php7-bcmath php7-mbstring php7-ctype
sudo pecl install zip
Now that we have installed PHP and its required packages, we need to install the MapTiler driver. The MapTiler driver is a proprietary, closed-source plugin that TileServer PHP uses to generate tiles from MapTiler maps. You can download the MapTiler driver from the following link, specifying Alpine Linux as the operating system:
https://www.maptiler.com/download/tileserver-php-driver/
cd ~/tileserver-php
unzip ~/Downloads/tileserver-php-driver-*.zip "driver/*"
sudo cp ~/tileserver-php/driver/maptiler-php-*.so /usr/lib/php7/modules/
We have now installed all the required components for TileServer PHP. The last step is to configure it. We will create a basic configuration file that serves a map of OpenStreetMap data in vector format:
cat > ~/tileserver-php/config.json <<EOF
{
"data":
{
"mbtiles":
{
"src":"https://download.geofabrik.de/europe/great-britain-latest.osm.pbf",
"format":"pbf"
}
},
"name":"OpenStreetMap",
"description":"A map of OpenStreetMap data in vector format",
"attribution":"OpenStreetMap contributors",
"center":[0,0,3],
"format":"pbf",
"minzoom":0,
"maxzoom":14,
"bounds":[-180,-85.0511,180,85.0511],
"version":"2.0.0",
"template":"osm-liberty",
"source":"https://www.openstreetmap.org",
"type":"map"
}
EOF
We are now ready to start the TileServer PHP application. We will start the application using the built-in PHP web server for testing purposes:
cd ~/tileserver-php
php -S localhost:8080
In this tutorial, we have gone through the steps to install TileServer PHP on Alpine Linux Latest. We have installed the required packages, downloaded and unzipped TileServer PHP, installed PHP and its required packages, installed the MapTiler driver, configured TileServer PHP, and started the application. We can now view the map by navigating to http://localhost:8080 in a web browser.
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!