超级基本的uwsgi配置

时间:2014-04-14 18:59:54

标签: python uwsgi

我已经尝试了一些uwsgi教程,但无法在我的浏览器中运行一个简单的python脚本。 我已经通读了这个(http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html)和这个(https://www.digitalocean.com/community/articles/how-to-deploy-python-wsgi-applications-using-uwsgi-web-server-with-nginx)和其他人,但由于某些原因无法运行简单的uwsgi应用。我目前没有通过网络服务器,只是uwsgi本身。

我有以下wsgi.py:

def application(env, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
return ["Hello!"]

我跑:

uwsgi --socket 127.0.0.1:8080 --chdir /my/program/path --pp .. -w wsgi

产生以下输出(看起来很有希望):

*** Starting uWSGI 2.0.3 (64bit) on [Mon Apr 14 12:51:32 2014] ***
compiled with version: 4.6.3 20120306 (Red Hat 4.6.3-2) on 14 April 2014 12:01:33
os: Linux-3.1.0-7.fc16.x86_64 #1 SMP Tue Nov 1 21:10:48 UTC 2011
nodename: ip-10-252-98-215
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /usr/oai/icscada/www
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8080 fd 3
Python version: 2.7.3 (default, Jul 24 2012, 11:41:40)  [GCC 4.6.3 20120306 (Red Hat 4.6.3-2)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x2504ee0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72752 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added ../ to pythonpath.
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x2504ee0 pid: 21702 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 21702, cores: 1)

但是当我从浏览器转到端口8080时,我得到一个"无法连接"错误。端口8080已打开并已经过测试。


我还尝试过以下wsgi.py:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

完全相同的结果

1 个答案:

答案 0 :(得分:5)

如果您想在没有Web服务器的情况下运行uWSGI,请使用http选项而不是socket。请参阅Native HTTP support

另外,如果从远程计算机访问,请使用0.0.0.0:80作为地址。