Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
litespeed_wiki:python_ajp_wsgi [2010/01/27 01:20] 127.0.0.1 external edit |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ''[[http://code.google.com/p/modwsgi/|mod_wsgi]] is an Apache module which "can host any Python application which supports the Python WSGI interface". Litespeed has no lsapi-wsgi yet at the time being(lsws 4.0.12), however, if an Python app running under apache with mod_wsgi, it can run under litespeed too through wsgi-ajp.'' | ||
- | |||
- | ====== the "Hello world" app ====== | ||
- | |||
- | ''/home/python_app>cat hello.py'' | ||
- | |||
- | |||
- | def application(environ, start_response): | ||
- | status = '200 OK' | ||
- | output = 'Hello World!' | ||
- | response_headers = [('Content-type', 'text/plain'), | ||
- | ('Content-Length', str(len(output)))] | ||
- | start_response(status, response_headers) | ||
- | return [output] | ||
- | |||
- | ====== Apache configuration ====== | ||
- | |||
- | ''mod_wgsi configuration in Apache httpd_conf:'' | ||
- | |||
- | LoadModule wsgi_module modules/mod_wsgi.so | ||
- | WSGIScriptAlias /hello /home/python_app/hello.py | ||
- | |||
- | ''access url: yourdomain.com/hello'' | ||
- | |||
- | ====== run the app in litespeed ====== | ||
- | |||
- | ==== 1.install ajp-wsgi ==== | ||
- | |||
- | http://www.saddi.com/software/ajp-wsgi/ | ||
- | |||
- | ==== 2. startup ajp-wsgi ==== | ||
- | |||
- | ''run ajp-wsgi in background:'' | ||
- | /home/python_app>ajp-wsgi -v -B -l ajp.log hello application /hello2 | ||
- | ''or run in foreground:'' | ||
- | /home/python_app>ajp-wsgi -v hello application /hello2 | ||
- | |||
- | ''above hello refer to /home/python_app/hello.py'' | ||
- | |||
- | ''/hello2 refer url: yourdomain.com/hello2'' | ||
- | |||
- | ==== 3.under Server or vhost, define a "Servlet Engine" External App ==== | ||
- | |||
- | ''when under Server, it's lsws admin console-->Server-->External App-->Add'' | ||
- | |||
- | ''Servlet Engine Definition example:'' | ||
- | |||
- | Name:ajp | ||
- | Address:127.0.0.1:8009 | ||
- | Max Connections:200 | ||
- | Connection Keepalive Timeout:30 | ||
- | Initial Request Timeout (secs):20 | ||
- | Retry Timeout (secs):0 | ||
- | Response Buffering:No | ||
- | |||
- | ==== 4.under a vhost, define a Servlet context ==== | ||
- | |||
- | ''Example of Servlet Context Definition:'' | ||
- | |||
- | URI:/hello2 | ||
- | Servlet Engine:[Server Level]: ajp | ||
- | |||
- | ''access url: yourdomain.com/hello2'' |