环境要求:Apache:2.2  Mysql:5.5 Django:1.5 python:2.7

首先下载mod_wsgi-win32-ap22py27-3.3.so

下载下来后,改名成mod_wsgi.so 拷贝到Apache下modules文件夹里

然后在Apache下conf文件里打开httpd.conf文件,在文件末尾加上以下的语句:

LoadModule wsgi_module modules/mod_wsgi.so

WSGIScriptAlias / "D:/test/src/django.wsgi"

<Directory "D:/test/">
AllowOverride none
Allow from all
</Directory>

期中上文中src是我的工程名。

然后在我的src的工程下建立一个django.wsgi文件,内容为:

import os
import sys
import django.core.handlers.wsgi
abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.environ['DJANGO_SETTINGS_MODULE'] = 'src.settings'
application = django.core.handlers.wsgi.WSGIHandler()

然后重启Apache就可以了。

我配置的时候参考http://blog.csdn.net/xyw_blog/article/details/9132335这篇文章,

文章上说还需要再配置一下setting.py文件,我没有配置也成功。先记下来吧:

MEDIA_ROOT = 'D:/test/src/src’
STATIC_ROOT = 'D:/test/src/src’
TEMPLATE_DIRS = (
"D:/test/src/src/templates",
)

在部署完成后,需要将debug关闭,

在settings.py,把"DEBUG=True"修改成“DEBUG = False”
 如果django使用的版本大于1.5版本的话,还需要把

“LLOWED_HOSTS = []”修改成“LLOWED_HOSTS = ['*']”。

在模板的目录下创建二个html文件,以供打开错误的网页显示。

分别为:404.html

<html>
No page!
</html>

500.html

代码为:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Page unavailable</title>
</head>
<body>
<h1>Page unavailable</h1> <p>Sorry, but the requested page is unavailable due to a
server hiccup.</p> <p>Our engineers have been notified, so check back later.</p>
</body>
</html>

即可。django部分部署完毕。

然后把apache映射出去,外网即可访问。具体参考我的另一篇文章:

http://www.cnblogs.com/lanye/p/3438503.html

最新文章

  1. jQuery:详解jQuery中的事件(二)
  2. 解决:Cannot get http://gerrit.googlesource.com/git-repo/clone.bundle
  3. React 快速入门小记
  4. WebRTC音视频引擎研究(1)--整体架构分析
  5. win10查看连接过的wifi密码
  6. Windows系统中Git的安装配置
  7. How do I use SOCKS proxy in delphi?
  8. py练习
  9. xcode UILabel创建和隐藏
  10. SQL Server 基础 02 确保数据完整性
  11. 常用的opengl函数(三)
  12. ajax-post请求
  13. Eclipse 项目以非gradle方式导入Android Studio
  14. mysql语法之case when then与列转行
  15. emitted value instead of an instance of error the scope attribute for scoped slots webpack babel polyfill
  16. Django - 将URL映射到视图
  17. ELK kibana查询与过滤
  18. 【转】【MFC】 StretchBlt绘图图像失真
  19. HDU 6031 Innumerable Ancestors
  20. [转]通过apk签名使应用程序有系统权限

热门文章

  1. 盘点:#AzureChat - 虚拟机和自动伸缩
  2. android ADT 设置编辑字体
  3. openssl生成pem,密钥证书的创建
  4. Bee Framework_百度百科
  5. android怎样实现自动点击功能
  6. 浅谈Jquery的使用下篇
  7. 14.18 InnoDB Backup and Recovery 备份和恢复:
  8. leetcode先刷_Path Sum
  9. JSP自定义标签——简单标签(2)
  10. 禁用win7自己主动配置ipv4地址