Ubuntu 11.10 with Nginx and uWSGI

7,405

Solution 1

You have daemonized uwsgi app server with /srv/www/site/logs/uwsgi.log as a log. The uwsgi log should contain information as to why it was unable to create the sock file in the first place.

Solution 2

Looking at your error.log it may be a permissions issue with the unix:///tmp/site.sock, in your uwsgi conf.ini you might use the chmod-socket option outlined here: uwsgi docs

Share:
7,405

Related videos on Youtube

devians
Author by

devians

Updated on September 18, 2022

Comments

  • devians
    devians over 1 year

    I'm trying to get a LNP [Linux Nginx Python] stack (is that even a thing? heh) going, but I'm having some difficulties.

    A lot of blog posts and documentation on doing this seems to revolve around using Upstart to manage the uWSGI process, which would be fine but I'm noticing that the packages installed with an init.d script and some config directories in /etc/uwsgi/{apps-enabled,apps-available}. So clearly there is a better way to do it.

    I have some config files (below), but I cannot seem to start the uwsgi process, running the init.d script does nothing, reports success but fails silently (without even a log).

    When i execute uWSGI directly i get this:

    % 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

    Also worth noting, the error thrown when I try to access the site:

    % 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 Config

    % 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 Config

    % 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;
        }
    }
    

    I'm using

    % 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
    

    Some version info

    % 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
    
    • Admin
      Admin about 11 years
      what is the content of /etc/uwsgi/apps-enabled/site.ini ? you showed cat /etc/uwsgi/apps-enabled/config.ini , not the file that you run with uwsgi.
  • devians
    devians over 12 years
    no log exists in that location.
  • devians
    devians over 12 years
    the socket is never created