接着上篇django在apache上须要下载mod_wsgi.so python
把扩张名whl改为zip,解压后会有mod-wsgi.so放在\Apache24\modules下, android
在文件conf/httd.conf中添加:LoadModule wsgi_module modules/mod_wsgi.so
web
这个按文件中的格式添加就行。 apache
启动apache,若是能启动起来就说明配置对了。不然就错了。最多见的错误就是mod_wsgi.so版本问题。上面的那个网站版本不全,能够在这里下载:http://download.csdn.net/detail/copter/9192361别人编译好的各个版本。 django
启动后就要配置django项目,有两种方法:在httpd.conf直接配置;在django建立个文件,在httpd.conf中包含进去。两种添加的内容都是同样的,推荐后者,扩张性更好: api
----------------------------------------------------------------------------------- 网站
1.。。。。直接在httpd.conf直接配置 WSGIScriptAlias / "C:/Users/liuxi_001/Desktop/web/MyBlog/MyBlog/wsgi.py"
WSGIPythonPath "C:/Users/liuxi_001/Desktop/web/MyBlog"
Alias /static "C:/Users/liuxi_001/Desktop/web/MyBlog/static"
<Directory "C:/Users/liuxi_001/Desktop/web/MyBlog/MyBlog">
<Files wsgi.py>
Require all granted
</Files>
</Directory> ui
2.。。。。 spa
建立apache-django-wsgi.conf,内容: .net
WSGIScriptAlias / "C:/Users/liuxi_001/Desktop/web/MyBlog/MyBlog/wsgi.py"
WSGIPythonPath "C:/Users/liuxi_001/Desktop/web/MyBlog"
Alias /static "C:/Users/liuxi_001/Desktop/web/MyBlog/static"
<Directory "C:/Users/liuxi_001/Desktop/web/MyBlog/MyBlog">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
在httpd.conf添加文件apache-django-wsgi.conf:
Include "xxxxx/web/MyBlog/apache_django_wsgi.conf"就是apache-django-wsgi.conf文件的目录。
运行原来的hello world。
注意:android访问django api须要关闭防火墙,要否则会一直提示timeout(我用的volley)。
设置setting.py debug=False是,要配置ALLOWED_HOSTS = ['192.168.1.126','127.0.0.1']红色添加进去的。
不然会报错:bad request:400