I want to do tile caching for MapServer map files by using TileCache application. For this I have installed Python 2.7 and TileCache 2.11 and applied the following sequence of steps:
- Extracted TileCache-2.11 tar file to my apache web directory into a folder tilecache Changed Disk Cache location in tilecache.cfg to my local folder
- Replaced name, srs, url with my map file in place of basic layer
- tested in browser using the url http://localhost:8088/tilecache/tilecache.cgi?LAYERS=APdem&&SERVICE=WMS&FORMAT=image/png&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&BBOX=-180,-90,0,90
But i'm getting tilecache.cfg python code in the browser as:
from TileCache import Service, cgiHandler, cfgfiles
if __name__ == '__main__':
svc = Service.load("tilecache.cfg")
cgiHandler(svc)
Is there any step missed in my process or what went wrong? In Linux the apache httpd.conf file is as follows
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /var/www/tilecache>
AddHandler cgi-script .cgi
Options +ExecCGI
</Directory>
DocumentRoot "/var/www/html"
<Directory /var/www/tilecache-2.11>
AddHandler cgi-script .cgi
Options +ExecCGI
</Directory>
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
# For type maps (negotiated resources):
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
the tilecache.cfg file is as follows
[cache]
type=Disk
base=/var/www/tilecache
[basic]
type=WMS
url=http://labs.metacarta.com/wms/vmap0
extension=png
[apdem]
type=WMS
url=https://test.com/mapserver/cgi-bin/mapserv?map=RMapFiles/apdem.map
extension=png
srs=EPSG:4326
layers=apdem
I have changed working directory in apache from html to cgi-bin the following error is appearing I extracted the tilecache code into cgi-bin and now the error was rectified with new error asAn error occurred:
File contains no section headers.
file: /var/www/cgi-bin/tilecache-2.11/tilecache.cfg, line: 1
'd# Configuration for MC TileCache\n'
File "/var/www/cgi-bin/tilecache-2.11/TileCache/Service.py", line 85, in _load
config.read(files)
File "/usr/lib64/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib64/python2.7/ConfigParser.py", line 512, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
2 Answers 2
After struggling one week I'm able to configure tilecache in Linux o.s. I also tested alongwith OL3 and working fine. The main problem is that the it is not reading tilecache.cfg files from correct path. So you have to give your absolute path for cfg files wherever required like in tilecache.cgi and services.py files. For mapserver service the mapscript module should be installed.
The TileCache installation instructions have one more step:
Permit CGI execution in the TileCache directory. For example, if TileCache is to be run with Apache, the following must be added in your Apache configuration, where /var/www/tilecache is the directory resulting from the code extraction. On Debian, this is typically /usr/lib/cgi-bin.
<Directory /var/www/tilecache> AddHandler cgi-script .cgi Options +ExecCGI </Directory>
-
This is already included.Satya Chandra– Satya Chandra2019年07月30日 04:22:02 +00:00Commented Jul 30, 2019 at 4:22
-
1It is included in the Apache configuration that listens on port 80. The server that listens on port 8088 apparently has no such configuration. What is running on 8088? Another Apache? What happens if you change the port to 80 in the URL?CL.– CL.2019年07月30日 06:34:24 +00:00Commented Jul 30, 2019 at 6:34
-
I have tested changed port also but same problemSatya Chandra– Satya Chandra2019年07月30日 06:42:28 +00:00Commented Jul 30, 2019 at 6:42
-
1Now it is giving error as, An error occurred: The requested layer () does not exist. Available layers are1: * apdemSatya Chandra– Satya Chandra2019年07月31日 09:24:01 +00:00Commented Jul 31, 2019 at 9:24
-
2The line
d# Configuration for MC TileCache
does not occur in the file shown in the question.CL.– CL.2019年07月31日 10:31:37 +00:00Commented Jul 31, 2019 at 10:31
svc = Service.load("C:\\TileCache\\tilecache.cfg")
but with your path