内部服务器错误与Nginx和uWSGI

我试图在Linode.com上使用Nginx的应用程序,但是我很早就被uWSGIconfiguration卡住了。

我已经使用了“入门”指南和“在Ubuntu 12.04(精准穿山甲)上使用uWSGI和nginx的WSGI”指南,并成功部署了Nginx(在浏览器中有Nginx的欢迎消息)。

尽pipe上面的教程是针对Ubuntu 12.04的,但我已经使用了14.04。

当我到达uWSGIconfiguration和“Hello World”Python应用程序时,问题就开始了。 到location /在浏览器返回Failed to load resource: the server responded with a status of 500 (Internal Server Error)并没有任何logging在服务器error.log。 location /static工作虽然和服务文件顺利。

我已经尝试了很多东西,并且广泛地在Google和Stackoverflow上进行了修复,但没有任何结果,现在我感到很沮丧。

感谢您的任何帮助。

这里是我的configuration文件(我已经隐藏我的域名和IP):

/etc/hosts

 127.0.0.1 localhost 127.0.1.1 ubuntu XX.XX.XX.XXX mars # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 

/etc/nginx/sites-enabled/example.com

 server { listen 80; server_name $hostname; access_log /srv/www/example.com/logs/access.log; error_log /srv/www/example.com/logs/error.log; location / { #uwsgi_pass 127.0.0.1:9001; uwsgi_pass unix:///run/uwsgi/app/example.com/example.com.socket; include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; } location /static { root /srv/www/example.com/public_html/; index index.html index.htm; } } 

/etc/uwsgi/apps-enabled/example.com.xml

 <uwsgi> <plugin>python</plugin> <socket>/run/uwsgi/app/example.com/example.com.socket</socket> <pythonpath>/srv/www/example.com/application/</pythonpath> <app mountpoint="/"> <script>wsgi_configuration_module</script> </app> <master/> <processes>4</processes> <harakiri>60</harakiri> <reload-mercy>8</reload-mercy> <cpu-affinity>1</cpu-affinity> <stats>/tmp/stats.socket</stats> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi> 

/srv/www/example.com/application/wsgi_configuration_module.py

 import os import sys sys.path.append('/srv/www/example.com/application') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/example.com/.python-egg' def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return 'Hello world!' 

last access log

 XX.XX.XX.XXX - - [05/Jul/2015:10:03:37 -0400] "GET / HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36" XX.XX.XX.XXX - - [05/Jul/2015:10:03:38 -0400] "GET /favicon.ico HTTP/1.1" 500 32 "http://example.com/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36" 

only error log I've got only one time when trying to fix this

 2015/07/05 08:49:06 [crit] 25301#0: *17 connect() to unix:///run/uwsgi/app/example.com/example.com.socket failed (2: No such file or directory) while connecting to upstream, client: XX.XX.XX.XXX, server: mars, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///run/uwsgi/app/example.com/example.com.socket:", host: "example.com" 2015/07/05 08:49:07 [crit] 25301#0: *17 connect() to unix:///run/uwsgi/app/example.com/example.com.socket failed (2: No such file or directory) while connecting to upstream, client: XX.XX.XX.XXX, server: mars, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///run/uwsgi/app/example.com/example.com.socket:", host: "example.com", referrer: "http://example.com/"