Django+apache+python+mod_python的环境搭建

来源:互联网 发布:巨人网络公司地址 编辑:程序博客网 时间:2024/05/02 02:29

1、首先确定本机已经安装的python版本,Django支持的版本为2.3-2.6,更高版本的python编译器不支持DJango的安装。在安装的时候会报错。

2、本机最早安装的版本为3.2 ,之后没办法又安装了2.5,不过python多版本可以共存,不用卸载其他的版本。

3、下载mod_python,apache注意各个程序版本的兼容性。

4、开始配置环境之前,确认一下本机各个软件的版本:

     python2.5

     Django1.3

     mod_python-3.3.1.win32-py2.5-Apache2.2

     apache2.2

5、解压Django,在Django目录中有个setyp.py文件,在命令行中运行:(这一步需要环境变量)

     python setup.py install

6、命令结束后会在D:\Python25\Lib\site-packages中生成django的目录。

7、将D:\Python25\Scripts、D:\Python25\Lib\site-packages\django\bin 添加到环境变量中。

8、安装apache2.2,这里安装过程很easy。

9、安装mod_python,这个过程在注册表中找到python2.5的安装路径,并要求手工制定apache的安装路径。

10、配置apache。

           Edit C:/Apache2.2\conf\httpd.conf,
           find where other LoadModule lines are and add this:
                LoadModule python_module modules/mod_python.so

11、创建测试工程,在命令行中执行:Django-admin.py startproject testmo。

12、命令执行完后会在当前工作目录中生成testmo文件夹,并声称一些初始化文件。

 C:\Users\Administrator\testmo 的目录2011/07/29  15:44    <DIR>          .2011/07/29  15:44    <DIR>          ..2011/07/29  15:44               517 manage.py2011/07/29  15:44             5,176 settings.py2011/07/29  15:44               582 urls.py2011/07/29  15:44                 0 __init__.py               4 个文件          6,275 字节               2 个目录 23,686,287,360 可用字节
13、执行manage.py runserver,得到如下提示信息:
Validating models...0 errors foundDjango version 1.3, using settings 'testmo.settings'Development server is running at http://127.0.0.1:8000/
14、访问页面,如果得到下面的信息,则配置成功:
It worked!Congratulations on your first Django-powered page.Of course, you haven't actually done any work yet. Here's what to do next:If you plan to use a database, edit the DATABASES setting in testmo/settings.py.Start your first app by running python testmo/manage.py startapp [appname].You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!


原创粉丝点击