Apache Configuration Wsgi

Source: Internet
Author: User
Tags writing test scripts

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.