web.py + uwsgi + nginx找不到应用程序

时间:2014-06-25 19:16:47

标签: python nginx uwsgi web.py

我正在尝试部署nginx uwsgi和web.py

这是我在/ www / python / testme /

中的index.py
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

这是我用uwsgi

的python的nginx配置
/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;
            }


    }

/etc/uwsgi/app-available/testme.ini中的Uwsgi 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

我的uwsgi服务正在运行,nginx按预期侦听端口8080。

当我从浏览器访问我的域时,错误日志如下: /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)

1 个答案:

答案 0 :(得分:3)

至少,这是错误的 - 你指定了2个不同的套接字

你的uwsgi配置:

socket = /tmp/testme.socket

你的nginx:

uwsgi_pass      unix:///tmp/test.socket