• 2009-01-22

    winxp+Apache+Mysql+Python+Django安装配置 - [技术空间]

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://www.blogbus.com/lily64-logs/34226333.html

    花了一天时间,终于完成了winxp下Apache+Mysql+Python+Django的安装。步骤如下:

    一,软件下载 

    1,
    http://www.apache.org/dist/httpd/modpython/win/3.3.1/
    下载mod_python-3.3.1.win32-py2.5-Apache2.2.exe 

    2,
    http://www.python.org/download/releases/2.5.4/
    下载python-2.5.4.msi

    3,
    http://www.djangoproject.com/download/
    下载Django-1.0.2-final.tar.gz

    4,
    http://sourceforge.net/projects/mysql-python/
    下载MySQL-python-1.2.2.win32-py2.5.exe

    二,安装

    1,安装python2.5

    2,安装mod_python-3.3

    3,安装Django-1.0
    将Django-1.0.2-final.tar.gz解压到python的安装目录下(本例为E:\Python25\Django),命令行进入E:\Python25,执行“python Django/setup.py install” ,Django即被安装到E:\Python25\Lib\site-packages\django下(E:\Python25\Django可删除)。

    4,安装MySQL-python-1.2
    (使python支持MySQL数据库)

    三,配置

    1,新建项目
    命令行进入E:\Python25\Lib\site-packages\django\bin,执行“django-admin.py startproject myproj”,新建名为myproj的项目。 

    2,新建py文件
    在E:\Python25\Lib\site-packages\django\bin\myproj目录下新建hello.py:

    from django.http import HttpResponse
    def index(request):
      return HttpResponse('Hello, Django! so hard *_*')

    3,配置apache的httpd.conf

    添加LoadModule python_module modules/mod_python.so

    添加
    <Location "/">
      SetHandler python-program
      PythonPath "['E:/Python25/Lib/site-packages/django/bin']+sys.path"
      PythonHandler django.core.handlers.modpython  
      SetEnv DJANGO_SETTINGS_MODULE myproj.settings
      PythonInterpreter inves
      PythonDebug Off
    </Location>

    4,修改urls.py文件

    修改E:\Python25\Lib\site-packages\django\bin\myproj目录下的urls.py:
    from django.conf.urls.defaults import *
    urlpatterns = patterns('',
      (r'^$', 'myproj.hello.index'),
    )

    四,运行

    重启apache服务,访问http://localhost/,即可看到以下信息:
    Hello, Django! so hard *_*

    五,参考链接

    1,http://hi.baidu.com/beloving/blog/item/32f65e60ab7c29de8cb10df9.html

    2,http://hideto.javaeye.com/blog/42538

    3,http://loamy.javaeye.com/blog/237161

    分享到: