nginx+uwsgi:——请求的不可用修饰符:0——?

nginx+uwsgi:——请求的不可用修饰符:0——?

我正在跟进在 Gentoo 上安装和配置 Nginx、uWSGI 和 Django。一切看起来都很好,直到最后一步:Nginx 返回 502 Bad Gateway 错误,uWSGI 日志中出现以下内容:

*** Starting uWSGI 1.2.4 (32bit) on [Mon Sep 10 23:41:29 2012] ***
compiled with version: 4.5.3 on 02 September 2012 22:00:55
detected number of CPU cores: 2
current working directory: /var/www/localhost/htdocs/mysite
writing pidfile to /var/run/uwsgi/trac.pid
detected binary path: /usr/bin/uwsgi
your memory page size is 4096 bytes
building mime-types dictionary from file /etc/mime.types...1017 entry found
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:8001 fd 3
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14105)
spawned uWSGI worker 1 (pid: 14108, cores: 1)
-- unavailable modifier requested: 0 --
-- unavailable modifier requested: 0 --

谷歌指向我,但对于 Ubuntu 来说。Gentoo 上的软件包的等效版本是什么uwsgi-plugin-python

/etc/nginx/nginx.conf

    location /mysite {
        root        /var/www/localhost/htdocs/mysite/polls;
        uwsgi_pass  127.0.0.1:8001;
        include     uwsgi_params;   
    }   

/etc/conf.d/uwsgi.trac

UWSGI_SOCKET="127.0.0.1:8001"
UWSGI_THREADS=0
UWSGI_PROGRAM=/var/www/localhost/htdocs/mysite/polls/tests.py
UWSGI_XML_CONFIG=
UWSGI_PROCESSES=1
UWSGI_LOG_FILE=/var/log/uwsgi/django.log
UWSGI_CHROOT=
UWSGI_DIR=/var/www/localhost/htdocs/mysite/
UWSGI_USER=uwsgi
UWSGI_EMPEROR_PATH=
UWSGI_EXTRA_OPTIONS=

答案1

首先,确保已uwsgi安装并python启用了 USE 标志:

[I] www-servers/uwsgi
     Available versions:  ~1.0.2.1 ~1.2.3-r3 ~1.2.3-r4 (~)1.2.4 {apache2 +caps +carbon cgi debug elibc_FreeBSD erlang gevent graylog2 json ldap lua +nagios +pcre perl php php_targets_php5-3 php_targets_php5-4 +python rrdtool rsyslog ruby ruby_targets_ree18 ruby_targets_ruby18 ruby_targets_ruby19 spooler sqlite syslog +xml yaml zeromq}
     Installed versions:  1.2.4(10:01:48 PM 09/02/2012)(apache2 caps carbon cgi ldap nagios pcre php_targets_php5-3 python ruby_targets_ruby18 ruby_targets_ruby19 xml -debug -elibc_FreeBSD -erlang -gevent -graylog2 -json -lua -perl -php -php_targets_php5-4 -rrdtool -rsyslog -ruby -ruby_targets_ree18 -spooler -sqlite -syslog -yaml -zeromq)
     Homepage:            http://projects.unbit.it/uwsgi/
     Description:         uWSGI server for Python web applications

其次,编辑初始化脚本并将UWSGI_EXEC变量更改/usr/bin/uwsgi_python27/usr/bin/uwsgi

PROGNAME=${SVCNAME#*.}

#UWSGI_EXEC=/usr/bin/uwsgi
UWSGI_EXEC=/usr/bin/uwsgi_python27
PIDPATH=/var/run/uwsgi
PIDFILE="${PIDPATH}/${PROGNAME}.pid"

然后重新启动uwsgi并重试。

答案2

仅适用于应用程序。只需在插件中设置所需的 Python 版本即可。

例子/etc/uwsgi.d/mysite.ini

[uwsgi]
plugins = python27

相关内容