超基础uwsgi配置 [英] Super basic uwsgi configuration

查看:37
本文介绍了超基础uwsgi配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've tried some uwsgi tutorials but can't get a simple python script to run in my browser. Ive read through this (http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html) and this (https://www.digitalocean.com/community/articles/how-to-deploy-python-wsgi-applications-using-uwsgi-web-server-with-nginx) and others, but for some reason can't get a simple uwsgi app running. I am currently not going through a web server, just uwsgi by itself.

我有以下 wsgi.py:

I have the following 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

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

which produces the following output (looks promising):

*** 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端口已开放并已测试.

but when I go to port 8080 from my browser I get a "could not connect" error. Port 8080 is open and has been tested.

我也尝试了以下 wsgi.py:

I've also tried the following wsgi.py:

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

完全一样的结果

推荐答案

如果你想在没有 web 服务器的情况下运行 uWSGI,请使用 http 选项而不是 socket.请参阅原生 HTTP 支持.

If you want to run uWSGI without a web server in front of it, use http option instead of socket. See Native HTTP support.

此外,如果您从远程机器访问,请使用 0.0.0.0:80 作为地址.

Also, use 0.0.0.0:80 as an address if you are accessing from a remote machine.

这篇关于超基础uwsgi配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆