Nginx在Ubuntu Server 13.1上出现错误

时间:2014-03-22 16:34:03

标签: ubuntu nginx flask uwsgi ubuntu-server

您好我正在尝试使用Flask在我通过ssh访问的Ubuntu 13.1服务器上设置一个restful api。我以为我已经正确设置了nginx和uwsgi,但是当我在浏览器中导航到我的IP地址(xxx.xxx.x.xxx)时,我得到以下消息而不是经典的nginx欢迎页面:

"发生错误。抱歉,您要查找的页面目前无法使用。 请稍后再试。如果您是此资源的系统管理员,则应检查错误日志以获取详细信息。"

当我在这里查看nginx错误日志时,我看到了:

2014/03/22 08:51:12 [crit] 23903#0: *1 connect() to unix:/tmp/uwsgi.sock failed (2: No such file or directory) while connecting to upstream, client: xxx.xxx.x.2xx, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/tmp/uwsgi.sock:", host: "xxx.xxx.x.1xx"

我遵循的教程是:http://conra.dk/2012/05/06/flask-uwsgi-nginx-ubuntu.html

以下是我的文件:

/etc/apt/sources.list.d/nginx-lucid.list:

deb http://nginx.org/packages/ubuntu/ lucid nginx
deb-src http://nginx.org/packages/ubuntu/ lucid nginx

/etc/init/uwsgi.conf

description "uWSGI"
start on runlevel [2345]
stop on runlevel[06]

respawn

exec uwsgi --master --processes 4 --die-on-term --uid uwsgi --gid nginx --socket /tmp/uwsgi.sock --chmod-socket 660 --no-site --vhost --logto /var/log/uwsgi.log

/etc/logrotate.d/uwsgi

/var/log/uwsgi.log {
    rotate 10
    daily
    compress
    missingok
    create 640 uwsgi adm
    postrotate
        initctl restart uwsgi >/dev/null 2>&1
    endscript
}

/etc/nginx/conf.d/helloworld.conf

server {
    listen       80;
    server_name  localhost;

    location /static {
        alias /srv/www/helloworld/static;
    }

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /srv/www/helloworld/env;
        uwsgi_param UWSGI_CHDIR /srv/www/helloworld;
        uwsgi_param UWSGI_MODULE application;
        uwsgi_param UWSGI_CALLABLE app;
    }

    error_page   404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

所以当我使用:

重新启动uwsgi时
sudo service uwsgi restart

我收到此消息:

stop: Unknown instance: 
uwsgi start/running, process 23969

然后当我尝试运行时

uwsgi --http 127.0.0.1:9090 --pyhome ./env --module application --callable app

我收到此消息:

*** Starting uWSGI 2.0.3 (64bit) on [Sat Mar 22 09:31:52 2014] ***
compiled with version: 4.8.1 on 22 March 2014 08:00:25
os: Linux-3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
nodename: upsilon
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /srv/www/helloworld
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 31452
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 127.0.0.1:9090 fd 4
spawned uWSGI http 1 (pid: 23989)
uwsgi socket 0 bound to TCP address 127.0.0.1:39396 (port auto-assigned) fd 3
Python version: 2.7.5+ (default, Feb 27 2014, 19:40:54)  [GCC 4.8.1]
Set PythonHome to ./env
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x2667f70
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72752 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./application.py", line 1, in <module>
    from flask import Flask
ImportError: No module named flask
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 23988, cores: 1)

0 个答案:

没有答案