apache+mod_wsgi配置

 2023-09-13 阅读 16 评论 0

摘要:apache+mod_wsgi配置 - Healich - ITeye技术网站apache+mod_wsgi配置 博客分类:PythonApachePythonDjangoGoogle脚本在apache下配置mod_wsgiApache http Server: http://httpd.apache.org/ modwsgi: http://code.google.com/p/modwsgi/, http://code.google.co

apache+mod_wsgi配置 - Healich - ITeye技术网站

apache+mod_wsgi配置

博客分类:Python
ApachePythonDjangoGoogle脚本
在apache下配置mod_wsgi

  • Apache http Server: http://httpd.apache.org/
  • modwsgi: http://code.google.com/p/modwsgi/, http://code.google.com/p/modwsgi/wiki/InstallationInstructions
  • WSGI: http://www.python.org/dev/peps/pep-0333/




在安装好apache之后,还需要下载mod_wsgi.mod_wsgi是用于apache支持python wsgi协议的扩展,当前版本是3.3,有windows下支持不同python版本的二进制文件下载。



首先需要使apache httpd服务器加载wsgi_module扩展。将下载的mod_wsgi.so置于apache serverr安装目录的modules文件下,在httpd.conf文件中添加如下一行:


Java代码  收藏代码
  1. LoadModule wsgi_module modules/mod_wsgi.so  
LoadModule wsgi_module modules/mod_wsgi.so




使用WSGIScriptAlias指令来指定wsgi application的启动脚本。在httpd.conf中添加如下一行,这里使用默认的DocumentRoot:


Java代码  收藏代码
  1. WSGIScriptAlias /test "/path/to/docRoot/test.wsgi"  
WSGIScriptAlias /test "/path/to/docRoot/test.wsgi"

apache怎么配置,
在/test路径下访问测试程序,wsgi脚本文件为test.wsgi




Python代码  收藏代码
  1. def application(environ, start_response):  
  2.     status = '200 OK'   
  3.     output = 'Hello World!'  
  4.   
  5.     response_headers = [('Content-type''text/plain'),  
  6.                         ('Content-Length', str(len(output)))]  
  7.     start_response(status, response_headers)  
  8.   
  9.     return [output]  
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]




重启apache sever之后,可以通过http://localhost/test来访问测试程序了。如果显示“Hello World!”则表明mod_wsgi安装成功。



配置apache

...



django在apache下的配置

http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/#howto-deployment-modwsgi

...

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/4/52925.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息