1

I'm trying to host an app using Nginx on Linode.com but I'm stuck early on uWSGI config.

I've used "Getting Started" guide and "WSGI using uWSGI and nginx on Ubuntu 12.04 (Precise Pangolin)" guide and I've succesfully deployed Nginx (got Nginx welcome message in browser).

Although above tutorial is for Ubuntu 12.04 I've used 14.04.

The problem starts when I got to uWSGI configuration and 'Hello World' Python app. Going to location / in browser returns Failed to load resource: the server responded with a status of 500 (Internal Server Error) and nothing gets logged in server error.log. location /static works though and serves files without a hitch.

I've tried many things and looked extensively for fix on Google and Stackoverflow but nothing, and I'm kind of frustrated right now.

Thank you for any help.

Here are my config files (I've hidden my domain and 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/"
2
  • 1
    The log is clearly stating that uWSGI it is not running. Have you launched the process? Jul 5, 2015 at 17:37
  • Normally I don't get any error log entry with this "Internal Server Error". This single error log was made when I was trying a couple of things to fix this thing (like running uWSGI on different user, running it with different flags, etc.) and you might be right, I probably could forgot to start uWSGI then. But still, it doesn't solve the problem :( Jul 5, 2015 at 18:25

0

You must log in to answer this question.

Browse other questions tagged .