How to build mod_wsgi, 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: 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/
WSGIScriptAlias /wsgi/ /u/local/www/wsgi-scripts/
WSGIApplicationGroup admin-scripts
Order allow,deny
Allow from all
WSGIDaemonProcess processes=2 threads=15
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]
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: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s