资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

apache+mod_wsgi+django配置

在不完全明白之前,看别人的帖子总是觉得是错的,等到弄懂以后,怎么看都是对的。

正题:

创新互联建站坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的高安网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

安装mod_wsgi,然后记得在http.conf文件里面添加以下一行:
LoadModule wsgi_module modules/mod_wsgi.so

此时的apache就是wsgi服务器了。也许有人会问什么是wsgi服务器。

# -*- coding: utf-8 -*- from wsgiref import simple_server def application(environ, start_response): status = \'200 OK\' output = \'Hello World!\' response_headers = [(\'Content-type\', \'text/plain\'), (\'Content-Length\', str(len(output)))] start_response(status, response_headers) return [output] # 下面两行就是简单的wsgi服务器 server = simple_server.make_server(\'localhost\', 8080, application) server.serve_forever()

注意这行:

server = simple_server.make_server(\'localhost\', 8080, application) 的参数application。这在apache里肯定无法编译进去,所以需要你在你的虚拟主机配置文件的
WSGIScriptAlias / /path/to/your/main.wsgi
行指出,而文件/path/to/your/main.wsgi的内容可能如下:

def application(environ, start_response): status = \'200 OK\' output = \'

Hello World!

\' response_headers = [(\'Content-type\', \'text/plain\'), (\'Content-Length\', str(len(output)))] start_response(status, response_headers) return [output] 或者
WSGIScriptAlias / /path/to/your/site/wsgi.py
然后wsgi.py就是django自动生成的文件。


当前文章:apache+mod_wsgi+django配置
转载注明:http://cdkjz.cn/article/cggpde.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220