Python – web.py + uwsgi + nginx no application found

nginxpythonuwsgiweb.py

i'm trying to deploy nginx uwsgi and web.py

Here is my index.py in /www/python/testme/

import web

urls = (
  '/', 'index'
)

app = web.application(urls, globals())

class index:
        def GET(self):
                return "Hello, world!"

if __name__ == "__main__": app.run()

application = app.wsgifunc

Here is my nginx configuration for python with uwsgi

/etc/nginx/sites-available/python
    server {
            listen          8080;
            server_name     $hostname;
            access_log /www/python/testme/logs/access.log;
            error_log /www/python/testme/logs/error.log;

            location / {
                #uwsgi_pass      127.0.0.1:9001;
                uwsgi_pass      unix:///tmp/test.socket;
                include         uwsgi_params;
                uwsgi_param     UWSGI_SCHEME $scheme;
                uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
            }


    }

Uwsgi ini in /etc/uwsgi/app-available/testme.ini

[uwsgi]
gid = www-data
uid = www-data
logdate = true
logto = /var/log/uwsgi/testme.log
socket = /tmp/test.socket
#socket = 127.0.0.1:3031
master = true
plugins = python

My uwsgi service is working, and nginx is listening port 8080 as expected.

How ever when i access my domain from browser here is error log:
/var/log/uwsgi/testme.log

ImportError: No module named index
Wed Jun 25 19:14:54 2014 - unable to load app 0 (mountpoint='') (callable not found or import error)
Wed Jun 25 19:14:54 2014 - --- no python application found, check your startup logs for errors ---
[pid: 32604|app: -1|req: -1/5] 46.197.209.106 () {48 vars in 919 bytes} [Wed Jun 25 19:14:54 2014] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0)
ImportError: No module named index
Wed Jun 25 19:14:54 2014 - unable to load app 0 (mountpoint='') (callable not found or import error)
Wed Jun 25 19:14:54 2014 - --- no python application found, check your startup logs for errors ---
[pid: 32604|app: -1|req: -1/6] 46.197.209.106 () {46 vars in 839 bytes} [Wed Jun 25 19:14:54 2014] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0)

Best Answer

at the very least, this is wrong -- you have 2 different sockets specified

your uwsgi config:

socket = /tmp/testme.socket

your nginx:

uwsgi_pass      unix:///tmp/test.socket
Related Topic