python - Internal Server Error with Nginx and uWSGI -
i'm trying host app using nginx on linode.com i'm stuck on uwsgi config.
i've used "getting started" guide , "wsgi using uwsgi , nginx on ubuntu 12.04 (precise pangolin)" guide , i've succesfully deployed nginx (got nginx welcome message in browser).
although above tutorial ubuntu 12.04 i've used 14.04.
the problem starts when got uwsgi configuration , 'hello world' python app. going location /
in browser returns failed load resource: server responded status of 500 (internal server error)
, nothing gets logged in server error.log. location /static
works though , serves files without hitch.
i've tried many things , looked extensively fix on google , stackoverflow nothing, , i'm kind of frustrated right now.
thank help.
here config files (i've hidden domain , ip):
/etc/hosts
127.0.0.1 localhost 127.0.1.1 ubuntu xx.xx.xx.xxx mars # following lines desirable 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, 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, gecko) chrome/43.0.2357.130 safari/537.36"
only error log i've got 1 time when trying fix this
2015/07/05 08:49:06 [crit] 25301#0: *17 connect() unix:///run/uwsgi/app/example.com/example.com.socket failed (2: no such file or directory) while connecting 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() unix:///run/uwsgi/app/example.com/example.com.socket failed (2: no such file or directory) while connecting 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/"
i not understand /etc/nginx/sites-enabled/dev.host.in? how or why *.in? think u should try it
step 1. create project.ini file # django_project.ini file [uwsgi] # django-related settings # base directory (full path) chdir = /home/username/django_project # django's wsgi file module = blog.wsgi # virtualenv (full path) home = /home/username/env/project # process-related settings master = true pidfile = /tmp/proj_uwsgi.pid # maximum number of worker processes processes = 5 # socket socket = :8001 # ... appropriate permissions - may needed # chmod-socket = 664 # clear environment on exit vacuum = true # background process daemonize = /home/username/django_project/error_uwsgi.log step 2. create mysite.conf in nginx, vim /etc/nginx/conf.d/mysite.conf upstream django { #server unix:///home/username/django_project/djproj.sock; # file socket server 127.0.0.1:8001; # web port socket (we'll use first) } # configuration of server server { # port site served on listen 80; # domain name serve server_name localhost mysite.com www.mysite.com; # substitute machine's ip address or fqdn charset utf-8; # max upload size client_max_body_size 75m; # adjust taste # django media location /media { alias /home/username/django_project/media; # django project's media files - amend required } location /static { alias /home/username/django_project/static; # django project's static files - amend required } # finally, send non-media requests django server. location / { uwsgi_pass 127.0.0.1:8001;#project; include /home/username/django_project/uwsgi_params; # uwsgi_params file installed } } step 3. ln -s /etc/nginx/uwsgi_params /home/username/django_project/ step 4. uwsgi --ini django_project.ini uwsgi --stop /tmp/proj_uwsgi.pid uwsgi --reload /tmp/proj_uwsgi.pid
Comments
Post a Comment