6

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 
1
  • 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. Commented Mar 16, 2013 at 8:06

4 Answers 4

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.

1
  • no log exists in that location. Commented Jan 9, 2012 at 13:58
1

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

1
  • 1
    the socket is never created Commented Jan 15, 2012 at 5:27
0

I always suggest new users to begin with the official quickstart, as uWSGI is built with the idea (that you can like or not) that each app is different from the others, and each one requires a specific tuning. So configuring it without fully understanding of the basic concepts could be a real (real) PITA.

By the way, it looks like you have a near-to-fully-working configuration, the wrong things i note are:

uwsgi_pass directive in nginx should be

uwsgi_pass unix:/tmp/site.sock

(no additional slashes)

You do not need to load the http plugin in the uWSGI instance, as nginx is natively using the uwsgi protocol.

Be sure that /srv/www/site/logs is writable by the www-data user and finally (as a suggestion), start using TCP sockets, as they do not require permissions and can be easily checked with tool like netstat.

Another note: you can try to run uwsgi manually with "uwsgi configfile" after having removed the "daemonize" option. In that way you could check for errors in your terminal.

0

I know this is quite late but after googling quite a bit If your socket isn't getting created you might have forgotten to create a link from the ./apps-enabled directory to the ./apps-available

sudo ln -s /etc/uwsgi/apps-available/mysite.ini /etc/uwsgi/apps-enabled/mysite.ini 

$ cat /etc/uwsgi/apps-enabled/README reads

Some files found in this directory are processed by uWSGI init.d script as uWSGI configuration files.

On system boot for each configuration file new uWSGI daemon instance is started with additional option. Name of this option is based on configuration file extension. Path to configuration files is passed as option value.

See more detailed information at: * /usr/share/doc/uwsgi/README.Debian.gz * /etc/default/uwsgi

of course you don't have to reboot the system, you can just sudo service uwsgi restart

Note: I just realized you're using 11.10 and I am using 12.04 so this may not work for you.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.