我正在关注这个在Gentoo上安装和configurationNginx,uWSGI和Django。 一切都看起来不错,直到最后一步:Nginx返回502错误的网关错误,以下内容出现在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 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=
首先,确保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
其次,编辑init脚本并将UWSGI_EXECvariables更改为/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试。
仅用于应用程序。 只需在插件中设置所需的Python版本。
示例/etc/uwsgi.d/mysite.ini :
[uwsgi] plugins = python27