Apache HTTP Server/mod wsgi
According to the project's site:
- The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.
mod_wsgi is an Apache module that embeds a Python application within the server and allow them to communicate through the Python WSGI interface as defined in the Python PEP 333. WSGI is one of the Python ways to produce high quality and high performance web applications.
WSGI provide a standard way to interface different web-apps without hassle. Several well-know python applications or frameworks provide wsgi for easy deployment and embedding. It means that you can embed your Django-powered blog and your project's Trac into a single Pylons application that wraps around them to deals with, say, authentication without modifying the formers.
Two packages are present in community:
- provides the module works with all common versions of Python (3.x)
- provides the module can only run with 2.x versions of Python
When you use mod_wsgi with Python 2.x better to install.
As indicated during installation, add the following line to the configuration file of Apache:
LoadModule wsgi_module modules/mod_wsgi.so
Check that Apache is running properly. If the previous command returned nothing, it means that the launch of Apache went well. Otherwise, you can see errors with the following command:
systemctl -l status httpd.service
Add this line in Apache configuration file:
WSGIScriptAlias /wsgi_app /srv/http/wsgi_app.py
Create a test file:
#-*- coding: utf-8 -*- def wsgi_app(environ, start_response): import sys output = sys.version.encode('utf8') status = '200 OK' headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, headers) yield output # mod_wsgi need the *application* variable to serve our small app application = wsgi_app
systemctl restart httpd
You can check the proper functioning by going to the following address : http://localhost/wsgi_app