1. Download Mod_wsgi, Address: http://code.google.com/p/modwsgi/downloads/list
2. After the download is complete (I am under the mod_wsgi-3.4.tar.gz)
Tar zxvf mod_wsgi-3.4.tar.gz
./configure--with-apxs=/home/aaron/httpd/bin/apxs--with-python=/usr/bin/python
Make && make install
This step is done, HTTPD's modules directory should have mod_wsgi.so
3. Modify the httpd.conf file and add:
LoadModule wsgi_module modules/mod_wsgi.so
4. Add the following line to the httpd.conf file, either server scope or VirtualHost (original: The directive can is used at server scope but normal Ly is placed withinthe VirtualHost container for a particular site):
Wsgiscriptalia/myapp/home/aaron/httpd/python/wsgi-scripts/myapp.wsgi
Wsgiscriptalia's first parameter represents the path to be bound to the WSGI application, and the second parameter is the path to the file on the server when accessing the WSGI application (when setting this path, be careful to create a specific directory, do not use $home, etc., the user has access rights, Easy to be hack)
5. Specify the access permissions for this path:
<directory "/home/aaron/httpd/python/wsgi-scripts" >
Require all granted
</Directory>
Note: The above is the syntax for Apache 2.4, and the 2.2 (previous) Version syntax description can be found in: http://blog.csdn.net/kittaaron/article/details/8940545
6. Write one of the simplest WSGI programs named Myapp.wsgi (corresponding to the 4th step, the following code is directly copied from the Http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide) , put it under the/home/aaron/httpd/python/wsgi-scripts/,
def application (environ, start_response): status = ' OK ' output = ' Hello world!
' response_headers = [(' Content-type ', ' Text/plain '),
(' Content-length ', str (output))] start_response (status, Response_headers) return [Output]
7. Restart httpd. should be able to access from Http://hostname:port/myapp and return to Hello World.
Reference: Http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
Http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide