How to Install TileServer PHP on Kali Linux Latest

TileServer PHP is an open-source software that allows you to serve tiles and raster maps from your own servers. This tutorial will guide you through the process of installing TileServer PHP on Kali Linux Latest.

Prerequisites

Step 1: Update Your System

Before we can install TileServer PHP, it's important to update all our system packages to the latest version:

sudo apt update
sudo apt upgrade

Step 2: Install Required Packages

We need to install some dependencies before installing TileServer PHP:

sudo apt install php7.2 php7.2-curl php7.2-gd php7.2-xml php7.2-zip composer git

Step 3: Download and Install TileServer PHP

Once all dependencies are installed successfully, we can now download and install TileServer PHP. We will use Git to download the latest version of TileServer PHP from Maptiler's Github repository:

cd /var/www # or the path where you wish to install TileServer PHP
sudo git clone https://github.com/maptiler/tileserver-php.git
cd tileserver-php
sudo composer install

Step 4: Configure Your Web Server

At this point, we have successfully installed TileServer PHP, but it won't be accessible until we configure our web server. We can configure either Apache or NGINX. For Apache, create a new virtual host file, and add the following content:

sudo nano /etc/apache2/sites-available/tileserver-php.conf

And add the following lines:

<VirtualHost *:80>
    ServerName your-domain-name.com # or server's IP address
    DocumentRoot /var/www/tileserver-php/public
    <Directory /var/www/tileserver-php/public>
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

For NGINX, add the following configuration:

server {
    listen 80;
    server_name your-domain-name.com; # or server's IP address
    root /var/www/tileserver-php/public;

    index index.php;
    charset utf-8;

    location / {
        try_files $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock; # check php-fpm socket directory
    }

    location ~* \.(png|jpe?g|gif)$ {
        expires 5d;
        add_header Cache-Control "public, max-age=432000, immutable";
    }

    location ~* \.(js|css)$ {
        expires 5d;
        add_header Cache-Control "public, max-age=432000, immutable";
    }
}

Save and close the file, then enable the newly created virtual host:

For Apache:
sudo a2ensite tileserver-php.conf

For NGINX:
sudo ln -s /etc/nginx/sites-available/tileserver-php /etc/nginx/sites-enabled/

Restart Apache or NGINX to apply the changes:

For Apache:
sudo systemctl restart apache2

For NGINX:
sudo systemctl restart nginx

Step 5: Verify the Installation

The last step is to verify the TileServer PHP installation by accessing it from a web browser. Launch your favorite web browser and visit the URL you have set up in your virtual host configuration.

http://your-domain-name.com/

If everything goes well, you should see a window showing a default OSM basemap. Congratulations! You have successfully installed and configured TileServer PHP on your Kali Linux Latest server. You can now add your own map data and start serving map data to the world.

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!