Installation and Configuration

The home page of TileCache is tilecache.org, where the source can be retrieved for installation. At the time of this writing, the current release is version 1.9 and options may vary with different releases.

To get started, we are going to assume a vanilla Red Hat-type operating system, such as Fedora 8, Red Hat Enterprise Linux 5 or CentOS 5. It is assumed that the Apache web server and the Python language environment are installed and that defaults are largely unchanged. Although we will install into your home directory, it is necessary to make minor modifications to system configuration files, so it will be necessary on a few occasions to have root access, either through su or sudo.

Apache Configuration

To get started, we will install into the public_html/ directory in our home directory. If this directory exists and Apache is configured correctly, it's contents are accessible through a web browser. Red Hat, however, ships with this facility disabled, so we must first enable it. As root, edit the file /etc/httpd/conf/httpd.conf and change the line

    UserDir disable

to

    UserDir public_html

Also, we need to enable CGI execution within the public_html and associate the .cgi extension with CGI handler. In /etc/httpd/conf.d/, create a file named tilecache.conf with the following contents:

<Directory /home/username/public_html/tilecache/bin/>
  Options +Indexes
</Directory>
AddHandler cgi-script .cgi

Then, reload Apache (as root):

#  /sbin/service httpd configtest && /sbin/service httpd graceful

Next create the directory, make a test file and try to retrieve it:

$  mkdir ~/public_html
$  echo 'Hello world!' > ~/public_html/test.txt
$  curl http://localhost/~username/test.txt
Hello world!

If that works as expected, then we have the minimal Apache setup required for TileCache to work.

Source Installation

Retrieve the tar.gz file from the TileCache web site and extract it from the tar archive:

$  curl http://www.tilecache.org/tilecache-1.9.tar.gz | tar zxf -

TileCache builds and installs using the standard Python distutils facility. For our purposes, the following command will suffice:

$  cd tilecache-1.9
$  python setup.py install --home ~/public_html
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /home/username/public_html/tilecache/bin/tilecache_http_server.py to 775
changing mode of /home/username/public_html/tilecache/bin/tilecache.fcgi to 775
changing mode of /home/username/public_html/tilecache/bin/tilecache.cgi to 775
changing mode of /home/username/public_html/tilecache/bin/tilecache_clean.py to 775
changing mode of /home/username/public_html/tilecache/bin/tilecache_seed.py to 775
running install_data
copying tilecache.cfg -> /etc
error: /etc/tilecache.cfg: Permission denied

In the last couple of lines, TileCache has foolishly attempted to disregard my --home option and tried to install its configuration file in /etc. We will therefore need to modify TileCache to look for tilecache.cfg in a different place. Also, to avoid ambiguities of Python module paths, we will expressly configure the path in the TileCache scripts. We also must copy the tilecache.cfg to ~/public_html/tilecache/

First, edit ~/public_html/tilecache/lib/python/TileCache/Service.py. Change line 12 from

cfgfiles = (os.path.join(workingdir, "tilecache.cfg"), os.path.join(workingdir,"..","tilecache.cfg"))

to

cfgfiles = ("/home/username/public_html/tilecache/tilecache.cfg","tilecache.cfg")

Next, edit ~/public_html/tilecache/bin/tilecache.cgi by inserting the following lines at line 2:

import sys
sys.path.append('/home/username/public_html/tilecache/lib/python/')

Add the same two lines to tilecache_seed.py at line 7.

If all has gone well, we should now be able to display TileCache's test layer. Copy either of the following URLs into your browser's location bar and modify the username as necessary.

http://localhost/~username/tilecache/bin/tilecache.cgi?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&BBOX=-180,-90,0,90&WIDTH=256&HEIGHT=25
http://localhost/~username/tilecache/bin/tilecache.cgi/1.0.0/basic/0/0/0.png

Figure 1.  TileCache Test Layer

TileCache Test Layer