hyzqb 发表于 2017-1-5 09:18:43

Django的Apache服务器配置

  Django的Apache服务器配置
  1. 环境
  Python 2.6.*
  Django 1.3.*
  Apahce 2.2.*
  mod_python.so
  2. mod_python安装下载
  
  a.下载地址
  官网:
  http://www.modpython.org/
  没有wins python 2.6的包
  Linux:
  http://archive.apache.org/dist/httpd/modpython/
  
  windows:
  http://download.csdn.net/detail/lanyx1/1337602
  mod_python-3.3.1.win32-py2.6-apache2.2.exe
  b. 安装
  Linux:
  (1).www.modpython.org下载源码包,解压后进入目录:
  执行:
  ./configure --with-apxs=/***/apache/bin/apxs --with-python=/usr/local/bin/python
   (2).make
   在这里编译会有报错,到
  https://bugzilla.redhat.com/show_bug.cgi?id=465246
  下载patch,并执行
  make install
   (3).配置mod_python.so
   会在/usr/local/lib/python2.6/site-packages/下生成一个mod_python目录
  同时在./src/.libs/下生成了一个mod_python.so,将这个so拷贝到apache的modules目录,并在httpd.conf中加入
  LoadModule python_module modules/mod_python.so
  
  windows:
  按提示安装
  c.测试
  
  
  d.Django项目配置:
  方法一:
  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    PythonPath "['E:/Python_Workspace/netqin/stats_ui'] + sys.path"
    SetEnv DJANGO_SETTINGS_MODULE statsui.settings
    PythonOption django.root /stats_ui
    PythonInterpreter inves
    PythonDebug Off
  </Location>
  
  Alias /static E:/Python_Workspace/netqin/stats_ui/static
  <Location "/static/">
  SetHandler None
  Order allow,deny
  Allow from all
  </Location>
  
  方法二:
  <VirtualHost *>
      ServerName www.euler.com
      # ...
      <Location "/">
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  PythonPath "['E:/Python_Workspace/netqin/stats_ui'] + sys.path"
  SetEnv DJANGO_SETTINGS_MODULE statsui.settings
  PythonOption django.root /stats_ui
  PythonInterpreter inves
  PythonDebug Off
      </Location>
  
      Alias /static E:/Python_Workspace/netqin/stats_ui/static
      <Location "/static/">
  SetHandler None
  Order allow,deny
  Allow from all
      </Location>
  </VirtualHost>
页: [1]
查看完整版本: Django的Apache服务器配置