Apache Configuration Wsgi What is Wsgi
Wsgi is called the Web server gateway interface, in the author's view is actually based on the CGI standard for the Python language to make some improvements, its main function is to standardize the Web server and PYTHONJ application interaction between the way, for Python in web development to provide convenience. About WSGI native development you can read the first link in the Reference section. This article explains how to configure WSGI so that the Apache server can support Python programs.
Operating Environment
Operating system: Ubuntu 16
Apache Server: Apache 2.4.18
python:2.7.12
Installing and loading the WSGI module
# sudo apt install libapache2-mod-wsgi
Enable the Wsgi module
# sudo a2enmod wsgi
Configure WSGI
Edit File /etc/apache2/mods-enabled/wsgi.conf
<IfModule mod_wsgi.c> WSGIScriptAlias/test/var/www/html/test.wsgi #添加该行</IfModule>
Writing test Scripts
Create the Test.wsgi file in the /var/www/html directory and add the following code to the file
def application(environ, start_response): =‘200 OK‘ =‘Hello World!‘ = [(‘Content-type‘‘text/plain‘), (‘Content-Length‘str(len(output)))] start_response(status, response_headers) return [output]
Access
To access the *http://address/test* in the browser, you can see "Hello world!" on the page.
Reference
WSGI native Development
Apache Configuration Wsgi
The deployment of Django on Aapache
Apache Configuration Wsgi