apache+python+tilecache配置(一)

1.安装[url=http://httpd.apache.org/]httpd-2.2.22-win32-x86-openssl-0.9.8t.msi[/url]
2.安装[url=http://www.python.org]python-2.5.msi[/url]
3.安装[url=http://www.modpython.org/]mod_python-3.3.1.win32-py2.5-Apache2.2.exe[/url]
4.配置httpd.conf
[color=green]第一步 加载mod_python[/color]
LoadModule python_module modules/mod_python.so

[color=green]第二步 添加处理程序.在mime_module中加入[/color]
    AddHandler cgi-script .cgi .pl
AddHandler mod_python .py
Include conf/extra/httpd-vhosts.conf
[color=green]第三步 配置#TileCache虚拟目录,AddHandler部分如果配了在第二部可以省掉[/color]
NameVirtualHost *:80
<VirtualHost *:80>
ServerName dummy-host.test.cn
ServerAlias www.dummy-host.test.cn
ErrorLog "logs/dummy-host.test.cn-error.log"
CustomLog "logs/dummy-host.test.cn-access.log" common
DocumentRoot "D:/server/tilecache-2.11"
<Directory "D:/server/tilecache-2.11/">
AddHandler mod_python .py
AddHandler python-program .py
PythonHandler TileCache.Service
PythonOption TileCacheConfig D:/server/tilecache-2.11/tilecache.cfg
PythonDebug On
PythonPath "['D:/server/tilecache-2.11/']+sys.path"
AllowOverride None
Options Indexes FollowSymLinks Multiviews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

[color=red]第14行很重要pythonPath如果没配好运行时碰到错误 [quote]ImportError: No module named TileCache.Service[/quote]解决办法在"运行",输入"Regedit",打开注册表编辑器,在注册表的
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\PythonPath]
位置下的键值中添加TileCache的位置"D:\server\tilecache-2.11\"[/color]
[color=green]第四步 配置TileCache的tilecache.cgi将第一行更改如下,保存后,将扩展名改成.py,配置好缓存[/color]
#!D:/dev/Python25/python.exe -u

[cache]
type=Disk
base=E:/TileCache

[url=http://127.0.0.1/tilecache/tilecache.py?LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180,0,-90,90&WIDTH=256&HEIGHT=256]查看单片[/url]
[url=http://127.0.0.1/index.html]查看全图[/url]
由于在TileCache的源码中还是默认调用了cgi的接口,这里为了彻底摆脱cgi,可以将TileCache目录下的tilecache.py修改为
import urllib2
from TileCache import Service, cgiHandler, cfgfiles, handler

if __name__ == '__main__':
# svc = Service.load(*cfgfiles)
# cgiHandler(svc)
handler(urllib2.Request)

同样service.py也修改为

if __name__ == '__main__':
# svc = Service.load(*cfgfiles)
# cgiHandler(svc)
handler(urllib2.Request)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值