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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值