windows+apache+mod_python配置django运行环境
时间:2021-02-01 04:06:54
1、创建mysite测试站点:django-admin.py startproject mysite
2、创建测试页:hello.py,内容如下:
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello, Django!')
3、创建mod_py_dj.conf配置文件,内容如下:
LoadModule python_module modules/mod_python_so.pyd
Listen 8081
NameVirtualHost *:8081
<VirtualHost *:8081>
<Location "/">
SetHandler python-program
PythonPath "['d:\open\www'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonAutoReload Off
PythonDebug On
</Location>
</VirtualHost>
注:此VirtualHost中,不用配置DocumentRoot,否则额外添加如下:
<Directory "d:\open\www">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
不配置DocumentRoot,少些配置。
4、修改url.py文件,添加一行:
(r'^hello/$', 'mysite.hello.index')
5、测试,http://localhost:8081/hello/
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python通过递归遍历出集合中所有元素的方法
在ASP中连接使用数据库
Python3 实现爬取网站下所有URL方式
Sql Server中存储过程中输入和输出参数(简单实例 一看就懂)
js保留两位小数方法总结
Python单向链表和双向链表原理与用法实例详解
![](https://img.aspxhome.com/file/2023/2/69522_0s.png)
Python基于locals返回作用域字典
在HTML中,常见的URL有多种表示方式:
Python实现从多表格中随机抽取数据
![](https://img.aspxhome.com/file/2023/1/83931_0s.png)
利用Python制作一个简单的天气播报系统
![](https://img.aspxhome.com/file/2023/6/118736_0s.jpg)
Access为后台数据库的网站统计系统
Python OpenCV直方图均衡化详解
![](https://img.aspxhome.com/file/2023/7/113047_0s.jpg)
python scipy.spatial.distance 距离计算函数
PHP实现手机归属地查询API接口实现代码
Python实现对word文档添加密码去除密码的示例代码
![](https://img.aspxhome.com/file/2023/4/101634_0s.png)
python 爬虫请求模块requests详解
![](https://img.aspxhome.com/file/2023/9/131169_0s.png)
WML初级教程之从实际应用中了解WML
如何将自己的python库打包成wheel文件并上传到pypi
![](https://img.aspxhome.com/file/2023/9/78669_0s.png)
SQL Server 自动增长清零的方法
5款Python程序员高频使用开发工具推荐
![](https://img.aspxhome.com/file/2023/5/81585_0s.jpg)