apache+mod_wsgi配置

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

在apache下配置mod_wsgi




在安装好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  




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


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


在/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]  




重启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://www.cnblogs.com/lexus/p/2366005.html