Flask + Apache +wsgi

Source: Internet
Author: User

Colleagues use flask to write some code, need to use Apache run up. Let's record the construction process.

Environment: Ubuntu 12.04

1, install the relevant package:

Apt-get Install Python-flask Libapache2-mod-wsgi

Note: The original flask is required to be installed. (^_^!)

What does Wsgi do?

       wsgi  is a specification of a generic API for mapping between an underlying Web server and a Python Web application. WSGI itself is described by python  pep 0333 . The purpose of the WSGI specification is to provide a common mechanism for hosting a Python Web application on a range of Different Web servers supporting the Python programming language

WSGI is a generic specification interface between webserver and Python Web applications, designed to provide a common mechanism for the deployment of Python programs in different webserver

2. Apache Configuration:

to write a relatively simple

<virtualhost *:80> ServerName what.abc.comdocumentroot/var/www/vpn/wsgiscriptreloading on WSGIScriptAl IAS//VAR/WWW/WHAT/WHAT.WSGI <directory "/var/www/what/" > Order deny,allow allow from all </ Directory></virtualhost>

Note: Here to write a What.wsgi file

The file content is also relatively simple

Import syssys.path.insert (0, '/var/www/what/') from index import app as application

The first two lines if you say that what.wsgi with the script can actually not. "From index import app as application" Here the index is a parameter. See what your application file name is. If index.py here is index


The relationship is about the same as Apache----->wsgi--------->index.py


In addition encountered errors to go to Apache errorlog to find.

This article is from the "Road Ops" blog, please be sure to keep this source http://zhangkechen.blog.51cto.com/907591/1682045

Flask + Apache +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.