为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

炎炎设计 2019-03-30 11:33:09
[补充]关于uwsgi_params:官网上面是这么说的:ConfigurenginxforyoursiteYouwillneedtheuwsgi_paramsfile,whichisavailableinthenginxdirectoryoftheuWSGIdistribution,orfromhttps://github.com/nginx/nginx/blob/master/conf/uwsgi_paramsCopyitintoyourprojectdirectory.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#theupstreamcomponentnginxneedstoconnecttoupstreamdjango{#serverunix:///path/to/your/mysite/mysite.sock;#forafilesocketserver127.0.0.1:8001;#forawebportsocket(we'llusethisfirst)}#configurationoftheserverserver{#theportyoursitewillbeservedonlisten8000;#thedomainnameitwillserveforserver_name192.168.33.10;#substituteyourmachine'sIPaddressorFQDNcharsetutf-8;#maxuploadsizeclient_max_body_size75M;#adjusttotaste#Djangomedialocation/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:05os:Linux-3.2.0-23-generic#36-UbuntuSMPTueApr1020:39:51UTC2012nodename:precise64machine:x86_64clocksource:unixdetectednumberofCPUcores:2currentworkingdirectory:/home/vagrant/mysite/mysitedetectedbinarypath:/home/vagrant/mysite/bin/uwsgi!!!nointernalroutingsupport,rebuildwithpcresupport!!!***WARNING:youarerunninguWSGIwithoutitsmasterprocessmanager***yourprocessesnumberlimitis2782yourmemorypagesizeis4096bytesdetectedmaxfiledescriptornumber:1024lockengine:pthreadrobustmutexesthunderlock:disabled(youcanenableitwith--thunder-lock)uwsgisocket0boundtoTCPaddress:8001fd3Pythonversion:2.7.3(default,Dec182014,19:25:50)[GCC4.6.3]***Pythonthreadssupportisdisabled.Youcanenableitwith--enable-threads***Pythonmaininterpreterinitializedat0x1579b10yourserversocketlistenbacklogislimitedto100connectionsyourmercyforgracefuloperationsonworkersis60secondsmapped72768bytes(71KB)for1cores***OperationalMODE:singleprocess***WSGIapp0(mountpoint='')readyin0secondsoninterpreter0x1579b10pid:1655(defaultapp)***uWSGIisrunninginmultipleinterpretermode***spawneduWSGIworker1(andtheonly)(pid:1655,cores:1)
查看完整描述

2 回答

?
largeQ

TA贡献2039条经验 获得超7个赞

问题解决了。其实是因为/etc/nginx/sites-enabled/下面有两个配置文件:default和我自己配置的mysite_nginx.conf,nginx默认使用了default。删掉default就对了。
                            
查看完整回答
反对 回复 2019-03-30
?
犯罪嫌疑人X

TA贡献2080条经验 获得超4个赞

配置文件没有起作用,检查是否正确读取了nginx的配置文件,先用个最简单的demo测试是否配置文件按是否生效
                            
查看完整回答
反对 回复 2019-03-30
  • 2 回答
  • 0 关注
  • 534 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信