Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; '16,': 0.03; 'skip:[ 20': 0.04; 'interpreter': 0.05; 'skip:u 30': 0.07; 'socket': 0.07; '172': 0.09; 'craft': 0.09; 'http': 0.09; 'mentions': 0.09; 'mode:': 0.09; 'skip:/ 10': 0.09; '\xe2\x80\x94': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"-"': 0.16; '.py': 0.16; 'callable': 0.16; 'index;': 0.16; 'operational': 0.16; 'url:pocoo': 0.16; 'utterly': 0.16; 'webapp': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'app': 0.19; 'module': 0.19; 'working.': 0.19; 'cc:addr:python.org': 0.22; 'config': 0.24; 'example.': 0.24; 'phd': 0.24; 'script.': 0.24; 'tue': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'query': 0.26; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'skip:p 30': 0.29; 'dec': 0.30; 'mode': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'bunch': 0.31; 'cgi': 0.31; 'initialized': 0.31; 'anyone': 0.31; 'file': 0.32; 'this.': 0.32; 'run': 0.32; 'linux': 0.33; 'url:python': 0.33; 'running': 0.33; 'plain': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; "he's": 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'architecture': 0.38; 'server': 0.38; 'connections': 0.38; 'massive': 0.38; 'work?': 0.38; 'files': 0.38; 'pm,': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'most': 0.60; 'full': 0.61; 'simple': 0.61; 'decided': 0.64; 'to:addr:gmail.com': 0.65; 'it!': 0.67; '100': 0.79; 'add:': 0.84; 'does?': 0.84; 'plugins': 0.84; 'skip:/ 30': 0.84; 'spawned': 0.84; 'subject:you': 0.87; 'works!': 0.91; '***': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=FNvW24bVc7ZvsoUOzZlC6ebxmz4HhsefX0dSrii9G3Y=; b=d87mh0gKLqdZ/HoxJQ/inkFkuFkWoRym7SFCMGUEVSIBncX2cAj75uAORVCUNe4mJE NKYuXxaPkMQK+PVVoB0jTQ+A2Ysq1fI3ZRsHkZxwD2go3lzPWgNdgJo1/SOu6SfR2p8M gFArNH4ivlHg00mfePN0mFSKefhkaEymzv2KLkJlKW9y6+UExuTeJxcH5ISh0P2Fi7Co 5NQsdXB9ZtHkq9PdDbde65NyYUx39OW1D8B2rFcuhxdTl4+WG3LMV9x6ooaRKs7vpZUJ g68Of4is614izAUhIyUVVYKIc/cxiFVFeIfYD9UO3AlypQrVrG7eAu8SL9Uk8vtFsXE/ P9ig== MIME-Version: 1.0 X-Received: by 10.112.170.36 with SMTP id aj4mr36284378lbc.3.1418746841483; Tue, 16 Dec 2014 08:20:41 -0800 (PST) In-Reply-To: References: Date: Tue, 16 Dec 2014 17:20:41 +0100 Subject: Re: uWSGI, nGinx, and python on Wheezy: how do you configure it? From: Chris Warrick To: Veek M Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418746849 news.xs4all.nl 2846 [2001:888:2000:d::a6]:47833 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6973 X-Received-Body-CRC: 640934903 Xref: csiph.com comp.lang.python:82583 On Tue, Dec 16, 2014 at 4:01 PM, Veek M wrote: > Has anyone got the thing to work? I want to run some python database scri= pts > on nginx. Because that will have a simple web-UI, i decided to go with > uWSGI. It's proving to be a massive pain. > > I found a decent book for nginx and got that bit working. The query gets > sent to uWSGI but for some reason it can't find my script. > > Most of the documentation on the web is utterly horrid and will take a 4 > year PhD to understand. I don't undertsand the architecture of uWsgi - he= 's > got a bunch of modules and I don't undertsand what exactly is going on > inside it! > > less /etc/nginx/sites-enabled/default > location / { > include uwsgi_params; > uwsgi_pass unix:/run/uwsgi/app/uwsgi/sockete; > uwsgi_param UWSGI_PYHOME /usr/share/nginx/cgi; > uwsgi_param UWSGI_CHDIR /usr/share/nginx; > uwsgi_param UWSGI_SCRIPT index; #NOT SURE WHAT THIS DOES? > > > less /etc/uwsgi/apps-enabled/uwsgi.ini > [uwsgi] > plugins=3Dpython > socket=3D/tmp/uwsgi.socket > pythonpath=3D/usr/share/nginx/cgi/ > > Tue Dec 16 20:43:21 2014 - Python main interpreter initialized at 0x95cde= 0 > Tue Dec 16 20:43:21 2014 - your server socket listen backlog is limited t= o > 100 connections > Tue Dec 16 20:43:21 2014 - *** Operational MODE: preforking *** > Tue Dec 16 20:43:21 2014 - added /usr/share/nginx/cgi/ to pythonpath. > Tue Dec 16 20:43:21 2014 - *** no app loaded. going in full dynamic mode = *** > Tue Dec 16 20:43:21 2014 - *** uWSGI is running in multiple interpreter m= ode > *** > Tue Dec 16 20:43:21 2014 - spawned uWSGI master process (pid: 18792) > Tue Dec 16 20:43:21 2014 - spawned uWSGI worker 1 (pid: 18818, cores: 1) > Tue Dec 16 20:43:21 2014 - spawned uWSGI worker 2 (pid: 18819, cores: 1) > > > ::1 - - [16/Dec/2014:21:08:03 +0530] "GET /foo.py HTTP/1.1" 502 172 "-" > "Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0" > -- > https://mail.python.org/mailman/listinfo/python-list This is NOT how uwsgi works! You cannot use plain .py files with it, and for good reason =E2=80=94 CGI should be long dead. What you need to do is, you must write a webapp =E2=80=94 in Flask, for example. Then you must craft an .ini file that mentions this. With the http://flask.pocoo.org/ demo as /var/flask/hello.py (copy-pasting from my working site): --- nginx config -- location { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; } --- /etc/uwsgi/apps-enabled/hello.ini --- [uwsgi] emperor =3D true socket =3D 127.0.0.1:3031 chdir =3D /var/flask/ master =3D true threads =3D 5 module =3D %n callable =3D app plugins =3D python uid =3D http gid =3D http processes =3D 3 --- If /var/flask is a virtualenv, add: binary-path =3D /var/flask/bin/uwsgi virtualenv =3D /var/flask --=20 Chris Warrick PGP: 5EAAEA16