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