操作系统:Windows XP pro
服务器:Apache 2.2
程序:Python2.5、PHP5.2.6
数据库:Mysql5.0、SQLite3
框架:Django1.0
所需要程序:Python2.5安装文件、Django1.0压缩包、Apache2.2.4 for Windows x86安装文件、mod_python-3.3.1.win32-py2.5-Apache2.2.exe模块安装文件、PHP5.2.6安装包、mysql5.0安装包、MySQL-python-1.2.2.win32-py2.5.exe安装文件
安装步骤:
1.Python2.5:一步步确认就可以了,我的安装目录是c:\python25。然后配置环境变量PATH属性,这样可以保证在任何文件夹下使用命令行工具执行python命令,方法是:开始菜单>右键我的电脑>属性>高级>环境变量,找到Path一项,加入“C:\Python25;”,重启电脑。
Tips: 注意安装时候要选择使用权限为All Users
2.Django1.0:下载安装文件解压到一个目录,如c:\django1.0(该目录安装完成后可以删除),然后打开命令行工具(开始>运行>输入cmd回车),指定到django解压目录如
cd ../../django1.0
python setup.py install
python
>>> import django
>>> django.VERSION
3.Apache2.2:下载以后直接安装就可以了,我的安装目录在c:\apache2.2
Tips:各个文件都安装在了c盘下是为了便于配置,没有特别要求。另同python安装要选择使用权限为All Users。
4.mod_python:让Apache支持python程序,这是一个exe文件,直接安装就可以,最后会让你选择apache的路径,然后会提示如何修改Apache的httpd.conf文件(在C:\Apache2.2\conf,没修改一次要重启apache)
Important Note for Windows users, PLEASE READ!!!
1. This script does not attempt to modify Apache configuration,
you must do it manually:
Edit C:/Apache2.2\conf\httpd.conf,
find where other LoadModule lines are and add this:
LoadModule python_module modules/mod_python.so
2. Now test your installation using the instructions at this link:
http://www.modpython.org/live/current/doc-html/inst-testing.html
按照http://www.modpython.org/live/current/doc-html/inst-testing.html提示的方法进行测试是否安装后运行正常。
5.PHP5:让apache支持php,此操作可以参考php5中文手册,解压php文件到C:\PHP,把php.ini配置好,修改path路径增加c:\php;,然后再打开httpd.conf写入
# 对 PHP 5 用这两行:
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
# 配置 php.ini 的路径
PHPIniDir "C:/php"
PS:为了让php支持cookie及session需要做两个修改在php.ini上,session.save_path = "c:/php/session_tmp"及session.use_cookies = 1,如果需要使用phpmyadmin设置mysql的话就一定要做这些设置了
6.MySQL5:直接用exe安装,使用典型安装模式,设置密码,装完后打开php.ini把对mysql的支持打开即可。
7.安装mysql_python:直接下一步就可以完成。
8.让apache支持对django框架的支持:django本身自带了一个小型的测试服务器,通过runserver命令即可以执行,但不足以成为一个可以运营的web服务器,如果要apache支持django只需要简单设置即可以:在C:\Python25\Scripts可以看到django-admin.py,可以拷贝到一个django的工程目录,例如C:\django下面,然后运行命令行工具并指定路径到该目录,执行
python django-admin.py startproject myproject
__init__.py
manage.py
settings.py
urls.py
四个文件,然后修改httpd.conf文件,在最后加入
Alias /mysite C:/django/myproject
AddHandler mod_python .py
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonDebug On
PythonPath "['C:\django'] + sys.path"
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all