Ubuntu 11.10与Nginx和uWSGI

我正试图获得一个LNP [Linux Nginx Python]堆栈(甚至是一件事?嘿),但我遇到了一些困难.

很多博客文章和文件做这似乎是围绕着使用新贵管理uWSGI进程,这将是很好,但我注意到,与脚本init.d中安装的软件包,并在/ etc / uwsgi一些配置目录/ {启用应用程序-,应用程序可用}.显然,有一种更好的方法可以做到这一点.

我有一些配置文件(下面),但我似乎无法启动uwsgi进程,运行init.d脚本什么都不做,报告成功但是无声地失败(甚至没有日志).

当我直接执行uWSGI时,我得到了这个:

% sudo uwsgi -i /etc/uwsgi/apps-enabled/site.ini
tmp = /
[uWSGI] getting INI configuration from /etc/uwsgi/apps-enabled/site.ini

/usr/lib/uwsgi/plugins/python27_plugin.so

另外值得注意的是,当我尝试访问该站点时抛出的错误:

% cat logs/error.log 
2012/01/08 23:26:12 [crit] 9167#0: *13 connect() to unix://tmp/site.sock failed (2: No such file or directory) while connecting to upstream, client: 60.241.99.33, server: mysite.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix://tmp/site.sock:", host: "mysite.com"

uWSGI配置

% cat /etc/uwsgi/apps-enabled/config.ini 
[uwsgi]
uid = www-data
gid = www-data
home = /srv/www/site/myapp
socket = /tmp/site.sock
pythonpath = /srv/www/site/virtualenvs/default
harakiri = 60
daemonize = /srv/www/site/logs/uwsgi.log
plugins = http,python

Nginx配置

% cat /etc/nginx/sites-enabled/mysite.com 
server {
    listen 80;
    server_name mysite.com;
    access_log /srv/www/site/logs/access.log;
    error_log /srv/www/site/logs/error.log;
    root   /srv/www/site/public_html;
    index  index.html index.htm;


    location / {
        uwsgi_pass unix:///tmp/site.sock;
        include uwsgi_params;
    }

    location ~ /\. {
        access_log off;
        log_not_found off; 
        deny all;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)${
        access_log        off;
        log_not_found     off;
        expires           360d;
    }
}

我正在使用

% dpkg --get-selections | grep uwsgi
libapache2-mod-uwsgi        install
uwsgi                       install
uwsgi-core                  install
uwsgi-plugin-http           install
uwsgi-plugin-python         install
% dpkg --get-selections | grep nginx
nginx-common                install
nginx-extras                install
nginx-full                  deinstall

一些版本信息

% nginx -V                                                                                                                       
nginx: nginx version: nginx/1.0.5
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-development-kit --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-lua --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-http-push --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upload-progress --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-secure-download
% uwsgi --version
uWSGI 0.9.8.1-debian
最佳答案
您使用/srv/www/site/logs/uwsgi.log作为日志守护uwsgi app服务器. uwsgi日志应包含有关无法首先创建sock文件的原因的信息.

转载注明原文:Ubuntu 11.10与Nginx和uWSGI - 代码日志