Installing TileCache on RedHat/CentOS
-
Install Apache
./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –with-mpm=prefork
make
make install
rm -Rf /usr/local/apache2/htdocs/* -
Install mod_python-3.3.1
<br /> ./configure --with-apxs=/usr/local/apache2/bin/apxs<br /> make<br /> make install<br />
-
Install Python Imaging Library (PIL) – Imaging-1.1.6
<br /> python setup.py install<br />
Note: To check if PIL was successfully installed:
#python selftest.py
*\*Test Failed** 1 failures.
*** 1 tests of 57 failed.
47 ln -s /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so
48 ldconfig
49 python setup.py install
51 python selftest.py
54 rm -rf Imaging-1.1.6
55 tar -zxvf Imaging-1.1.6.tar.gz
56 cd Imaging-1.1.6
58 python selftest.py -> still fails
59 python setup.py install
60 python selftest.py -> ok
- Check if mod_python was sucessfully installed.
http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking
[root@rupert-centos pytest]# python Python 2.4.3 (#1, Mar 14 2007, 18:51:08) [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mod_python >>> mod_python.version '3.3.1' >>> |
- Edit httpd.conf
<directory> AddHandler python-program .py PythonHandler TileCache.Service PythonOption TileCacheConfig /usr/local/apache2/htdocs/tilecache/tilecache.cfg PythonDebug On PythonPath "sys.path + ['/usr/local/apache2/htdocs/tilecache/']" </directory> <directory> AddHandler mod_python .py PythonHandler test PythonDebug On </directory> |
Note: This syntax will work for all versions of mod_python. In version 3.0 and later, the name of the mod_python handler reference has actually been changed and thus it is now preferred to use “mod_python” instead of “python-program”. The old name though is still supported and will be used here to avoid confusion for those using version 2.7.
- Test your python
from mod_python import apache def handler(req): req.log_error('handler') req.content_type = 'text/plain' req.send_http_header() req.write('mptest.py\n') return apache.OK |