nginx不能应用mysite_nginx.conf中的配置,始终以默认配置启动

[补充]关于uwsgi_params:
官网上面是这么说的:
Configurenginxforyoursite
Youwillneedtheuwsgi_paramsfile,whichisavailableinthenginxdirectoryoftheuWSGIdistribution,orfromhttps://github.com/nginx/nginx/blob/master/conf/uwsgi_params
Copyitintoyourprojectdirectory.Inamomentwewilltellnginxtorefertoit.
[原文]
按照这个文档http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html部署uwsgi+nginx+django的时候,uwsgi和django或纯python配合都能出正确结果,安装了nginx之后也能在浏览器刷新看到Welcometonginx!。
然后我把nginx配置文件建立在django项目文件夹下面了:
#mysite_nginx.conf
#theupstreamcomponentnginxneedstoconnectto
upstreamdjango{
#serverunix:///path/to/your/mysite/mysite.sock;#forafilesocket
server127.0.0.1:8001;#forawebportsocket(we'llusethisfirst)
}
#configurationoftheserver
server{
#theportyoursitewillbeservedon
listen8000;
#thedomainnameitwillservefor
server_name192.168.33.10;#substituteyourmachine'sIPaddressorFQDN
charsetutf-8;
#maxuploadsize
client_max_body_size75M;#adjusttotaste
#Djangomedia
location/media{
alias/home/vagrant/mysite/mysite/media;#yourDjangoproject'smediafiles-amendasrequired
}
location/static{
alias/home/vagrant/mysite/mysite/static;#yourDjangoproject'sstaticfiles-amendasrequired
}
#Finally,sendallnon-mediarequeststotheDjangoserver.
location/{
uwsgi_passdjango;
include/home/vagrant/mysite/mysite/uwsgi_params;#theuwsgi_paramsfileyouinstalled
}
}
但无论是试图直接用test.py输出helloworld,还是启动django服务器,都仍然只能看到Welcometonginx!,服务器ip后面带上路径也是只有这个。
直接用test.py的时候输出如下:
$uwsgi--socket:8001--wsgi-filetest.py***StartinguWSGI2.0.9(64bit)on[MonFeb215:54:012015]***
compiledwithversion:4.6.3on02February201509:51:05
os:Linux-3.2.0-23-generic#36-UbuntuSMPTueApr1020:39:51UTC2012
nodename:precise64
machine:x86_64
clocksource:unix
detectednumberofCPUcores:2
currentworkingdirectory:/home/vagrant/mysite/mysite
detectedbinarypath:/home/vagrant/mysite/bin/uwsgi
!!!nointernalroutingsupport,rebuildwithpcresupport!!!
***WARNING:youarerunninguWSGIwithoutitsmasterprocessmanager***
yourprocessesnumberlimitis2782
yourmemorypagesizeis4096bytes
detectedmaxfiledescriptornumber:1024
lockengine:pthreadrobustmutexes
thunderlock:disabled(youcanenableitwith--thunder-lock)
uwsgisocket0boundtoTCPaddress:8001fd3
Pythonversion:2.7.3(default,Dec182014,19:25:50)[GCC4.6.3]
***Pythonthreadssupportisdisabled.Youcanenableitwith--enable-threads***
Pythonmaininterpreterinitializedat0x1579b10
yourserversocketlistenbacklogislimitedto100connections
yourmercyforgracefuloperationsonworkersis60seconds
mapped72768bytes(71KB)for1cores
***OperationalMODE:singleprocess***
WSGIapp0(mountpoint='')readyin0secondsoninterpreter0x1579b10pid:1655(defaultapp)
***uWSGIisrunninginmultipleinterpretermode***
spawneduWSGIworker1(andtheonly)(pid:1655,cores:1)
炎炎设计
浏览 535回答 2
2回答

largeQ

问题解决了。其实是因为/etc/nginx/sites-enabled/下面有两个配置文件:default和我自己配置的mysite_nginx.conf,nginx默认使用了default。删掉default就对了。

犯罪嫌疑人X

配置文件没有起作用,检查是否正确读取了nginx的配置文件,先用个最简单的demo测试是否配置文件按是否生效
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript