flask + apache +wsgi
同事用flask写了一些代码,需要用apache跑起来。下面记录一下搭建的过程环境:ubuntu 12.04
1、安装相关包:
apt-get install python-flasklibapache2-mod-wsgi
注: 原来flask是需要安装的。 (^_^!)
wsgi 是做什么的呢?
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 是介于webserver 和python web 应用之间的一通用性的规范接口,目的是提供一个通用的机制在不同的webserver 布 署python程序
2、apache的配置:
写一个比较简单的
ServerName what.abc.com
DocumentRoot/var/www/***/
WSGIScriptReloading On
WSGIScriptAlias / /var/www/what/what.wsgi
Order Deny,Allow
Allow from all
注: 这里要写一个what.wsgi的文件
文件内容也比较简单
import sys
sys.path.insert(0, '/var/www/what/')
fromindex import app as application 前两行如果说what.wsgi跟脚本们在一起其实也可以不要的。 "fromindex import app as application" 这里的index 是个参数。看你的应用程序文件名叫啥了。如果 index.py 这里就是index
关系大约是这样apache ----->wsgi--------->index.py
另外遇到错误去apache的errorlog中查找。
页:
[1]