How to build mod_wsgi,web.py with httpd and python from source code

It is best to compile everything from source code.Version used

Python: 2.7 (with shared library)httpd 2.2.17 (with shared DSO support)WSGI (integrating with httpd): mod_wsgi 3.3
Web framework: web.py 0.34

Compile Python for shared lib./configure –prefix= –enable-shared

 

Set up LD_LIBRARY_PATH so that running “python” would find its shared lib
export LD_LIBRARY_PATH=${python-lib}:$LD_LIBRARY_PATH
 


Compile (apache) httpd Add DSO support
./configure –prefix= –enable–module=module_soCompile mod_wsgi
./configure –with-apxs=$APACHE_HOME/bin/apxs –with-python=$PYTHON_BIN/python

Configure httpd.conf for mod_wsgi

 
 
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi/ /u/local/www/wsgi-scripts/
WSGIApplicationGroup admin-scripts
Order allow,deny
Allow from all
WSGIProcessGroup example1.com
WSGIDaemonProcess example1.com processes=2 threads=15 display-name=example1.com
Install a sample python code under /u/local/www/wsgi-scripts/sniff
import sys
def application(environ, start_response):
status = ‘200 OK’
output = ‘sys.version= %snsys.prefix=%sn’ % (sys.version, sys.prefix)
output += ‘sys.path= %sn’ % (sys.path)
response_headers = [(‘Content-type’, ‘text/plain’),
(‘Content-Length’, str(len(output)))]
start_response(status, response_headers)
return [output]
 
Advertisements
This entry was posted in apache2, python. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s