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