uwsgi模块在nginx和uwsgi服务器之间的区别 [英] difference between uwsgi module in nginx and uwsgi server

查看:191
本文介绍了uwsgi模块在nginx和uwsgi服务器之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是linux开发的新手。我对我阅读的文档有些困惑。
我的最终目标是托管一个简单的python支持的Web服务,它将检查传入的有效载荷,并将其转发到其他服务器。这应该在python中不到30行代码。



我打算使用nginx来提供python文件。从我的研究,我还需要一个python web框架。我选择用uwsgi去。我很困惑。我需要哪一个?一个nginx uwsgi模块,还是uwsgi服务器?我不想把django只是为了这个简单的目的。



nginx文档提到

p>


不要将uwsgi协议与uWSGI服务器混淆(说出uwsgi协议)


那么这是不是意味着我不需要单独安装uwsgi服务器?我只是安装nginx,并开始配置?我正在使用nginx 1.4.4



有人可以分享一步一步的配置过程,了解如何使用nginx配置uwsgi,以及一个示例python代码(hello world也许)?我可以配置nginx很好,但我不知道如何使它提供python页面。我可以找到的所有文档涉及到顶部有django。

解决方案

你正在混淆事情,所以让我澄清一下。



Python通过Web服务器发布应用程序的标准方式是 WSGI - 你可以认为它是一个Python的本地CGI。 uWSGI 是符合WSGI的服务器,使用 uwsgi 协议与其他uWSGI实例或上游服务器通信。通常上游服务器是 nginx ,其中 HttpUwsgiModule 允许它使用uwsgi协议进行通信 - 使用nginx,您可以为应用服务器提供额外的保护层,负载平衡和提供静态文件。在大多数情况下,您应该使用Nginx + UWSGI 。为了回答您的问题,uWSGI已经安装并与nginx分开运行,并且都需要配置为彼此通信。



纯WSGI是相当低级别的,因此您可能希望使用符合WSGI的 框架 。我猜前两个是 Django Flask



对于一个hello world Flask设置,服务烧瓶与Nginx 似乎是一个很好的文章。


I'm new to linux development. I'm a bit confused on the documentation i read. My ultimate goal is to host a simple python backed web service that would examine an incoming payload, and forward it to other server. This should be less than 30 lines of code in python.

I'm planning to use nginx to serve up python file. From my research, i also need a python web framework. I chose to go with uwsgi. I'm so confused. which one do I need? an nginx uwsgi module, or uwsgi server? i don't want to put django just for this simple purpose.

the nginx documentation mention that

Do not confuse the uwsgi protocol with the uWSGI server (that speaks the uwsgi protocol)

So, does that mean, i don't need to install uwsgi server separately? do i just install nginx, and start configuring? I'm using nginx 1.4.4

Could someone share a step by step configuration procedure on how to configure uwsgi with nginx, along with a sample python code(hello world maybe)? i can configure nginx just fine, but i don't know how to make it serve python pages. all the docs i could find involves having django on top.

解决方案

You're mixing up things, so let me clarify.

Python's standard way of publishing applications via web servers is WSGI--you can think of it as a Python's native CGI. uWSGI is a WSGI-compliant server that uses uwsgi protocol to talk to other uWSGI instances or upstream servers. Usually the upstream server is nginx with HttpUwsgiModule that allows it to communicate using uwsgi protocol--with nginx you have additional layer of protection for your app server, load balancing and serving the static files. In most scenarios, You Should Be Using Nginx + UWSGI. To answer your question, uWSGI is installed and run separately from nginx, and they both need to be configured to communicate to each other.

Pure WSGI is pretty low-level, so you may want to use a WSGI-compliant framework. I guess the top two are Django and Flask.

For a hello world Flask setup, Serving Flask With Nginx seems to be a good article.

这篇关于uwsgi模块在nginx和uwsgi服务器之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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