By Rupert
Posts tagged mod_python
Installing TileCache on RedHat/CentOS
Jul 25th
1. Install Apache
./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –with-mpm=prefork
make
make install
rm -Rf /usr/local/apache2/htdocs/*
2. Install mod_python-3.3.1
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
make install
3. Install Python Imaging Library (PIL) – Imaging-1.1.6
python setup.py install
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
4. 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' >>>
4. 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.
5. 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
TileCache for Windows Revisited
Jan 17th
1. Downloaded TileCache1.8 from http://www.tilecache.org/
2. Get the current releases of python and mod_python.
http://www.python.org/download/releases/2.5/
http://httpd.apache.org/modules/python-download.cgi -> click on win32 binaries. Get the mod_python-3.3.1.win32-py2.5-Apache2.2.exe if your Apache is running on 2.2.
http://www.pythonware.com/products/pil/
http://effbot.org/downloads/PIL-1.1.6.win32-py2.5.exe
3. Install python2.5
4. Install mod_python and python_imaging.
5. Edit httpd.conf
LoadModule python_module modules/mod_python.so <directory> AddHandler python-program .py PythonHandler test PythonDebug On </directory> <directory> AddHandler python-program .py .cgi PythonHandler TileCache.Service PythonOption TileCacheConfig /wwwroot/tilecache/tilecache.cfg PythonDebug On </directory> ScriptInterpreterSource Registry SetEnv PYTHONUNBUFFERED 1 PassEnv PYTHONPATH
6. run regedit. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.4\PythonPath. Append “E:\wwwroot\tilecache” to PYTHONPATH
D:\Python24\Lib;D:\Python24\DLLs;D:\Python24\Lib\lib-tk;E:\wwwroot\tilecache;
7. Put D:\Python24 in your WINDOWS PATH
8. Test if apache could read python by http://127.0.0.1/pytest/test.py
9. http://127.0.0.1/tilecache/test1.cfm
10. tilecache_seed.py “http://127.0.0.1/tilecache/tilecache.py” roads 12 17 “116.28229,39.85291,116.48657,39.98783″
Comments