window下配置前端nginx后端多apache(django_wsgi)
安装Apache 与 wsgi
安装nginx
Apache 中主要是对python的支持配置:
加入模块:
LoadModule wsgi_module modules/mod_wsgi.so
多个Apache配置:
1.端口 Listen 8080
2.Log文件位置3个
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
3.PidFile(这个我没改,window下没看到配置,可能是默认的)
4.添加python程序的配置:
WSGIScriptAlias / 'D:\workspace\Aptana Studio 2.0\django13Test\django13Test\django.wsgi'
<Directory 'D:\workspace\Aptana Studio 2.0\django13Test\django13Test'>
Order deny,allow
Allow from all
</Directory>
注:django.wsgi 是python脚本:
import os
import sys
import django.core.handlers.wsgi
sys.path.append(r'D:\workspace\Aptana Studio 2.0\lbforum_test')
#if 'DJANGO_SETTINGS_MODULE' in os.environ:
# logfile = open("C:\lbforum.log",'w');
# logfile.write(os.environ['DJANGO_SETTINGS_MODULE']);
# logfile.close();
os.environ['DJANGO_SETTINGS_MODULE'] = 'lbforum_test.settings'
application = django.core.handlers.wsgi.WSGIHandler()
1)D:\workspace\Aptana Studio 2.0\django13Test\django13Test\django.wsgi 指向这wsgi脚本路径,
2)<Directory 'D:\workspace\Aptana Studio 2.0\django13Test\django13Test'>
Order deny,allow
Allow from all
</Directory>
中的 “D:\workspace\Aptana Studio 2.0\django13Test\django13Test”路径不能配置出错,注意不要以“\”结尾!
3)django.wsgi文件中
sys.path.append(r'D:\workspace\Aptana Studio 2.0\lbforum_test')
“D:\workspace\Aptana Studio 2.0\lbforum_test”这个路径指的是项目(代码包的上一级路径)
而 os.environ['DJANGO_SETTINGS_MODULE'] = 'lbforum_test.settings'
lbforum_test.settings 是搜索django settings的配置
5.在window下注册服务(window就是烦)
link:http://microskype.blog.51cto.com/871494/191309/
6.启动你配置的多个apache,多个端口测试一下
nginx配置:
nginx配置就很简单了主要是请求的转发,url的规则
首先添加 upstream
upstream blog {
server localhost:8080;
}
upstream lbforum {
server localhost:808;
}
blog,lbforum分别是其名字:
然后再server中配置Url转发规则就可以了
location /blog/ {
proxy_pass http://blog;
}
location /lbforum/ {
proxy_pass http://lbforum;
}
location / {
proxy_pass http://lbforum;
}
以上只是简单配置,刚开始研究nginx apache django这些东西。可能会弄的很傻。附件内容是配置的详情