开始学习python,配置web环境并部署django

在vista下配置
1.下好并安装apache_2.2.11-win32-x86-openssl-0.9.8i.msi
2.下好 python3后发现没有匹配的Mod_python,在http://apache.mirror.phpchina.com/httpd/modpython/win/最新的Mod_python还是2007年2月的,仅支持python2.5。
重新下好python2.5,并设置好system path
3.安装Mod_python
4.根据http://www.modpython.org/live/current/doc-html/modpython.html的例子做测试
在apache 的 httpd.conf中设置
LoadModule python_module modules/mod_python.so
<Directory "D:/Apache Software Foundation/Apache2.2/htdocs/test">
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>
在/htdocs/下建立test目录,并建立mptest.py文件,编辑内容
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK
启动apache,http://localhost:8080/test/mptest.py,出现Hello World!,测试ok
5.安装Django,下载Django-1.0.2-final,解压后cmd到其目录执行python setup.py install, 会将django安装到python2.5目录中
6.建立一个目录 testDjango,将\Python25\Scripts下的django-admin.py copy过去,并执行python django-admin.py startproject myproject,会在testDjango下生存myproject目录和4个py文件
7.测试django,在httpd.conf中加入
<Location "/myproject">
SetHandler python-program
PythonPath "['D:/python/work/testDjango'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonDebug On
</Location>
重启apache,键入http://xxx:8080/myproject,出现django提示页面,ok
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值