uwsgi basic introduction to the installation and testing - using Django to build your first website

A basic introduction

    Like me do not a professional network of people, uuwsgi is a strange thing. who is it? What can it do? Who will use it?
In fact, without knowing what a thing is, it is able to quickly understand and use it, is a very artistic thing. The most important is that it is very valuable to you. It estimated that before you did not take a few minutes to understand it, you will not know if it's valuable to you. So, since you can search to my article, it would take a few minutes to look at it is estimated that after reading the first section, you will know whether there is a need to look at the second quarter.
Who should understand and use it?
Doing web development and technical personnel, business people want to do their own websites, as well as students who want to learn to understand web development, and should be more or less learn about the uwsgi. Because he is a very wide range of applications in the construction site.
What is it? The following passage is estimated to well explain your doubts.
uWSGI designed to network application development and deployment of distributed cluster of a complete solution. Mainly for its standard web services. Because of its scalability, it can be unlimited extension to support more platforms and languages. uWSGI is a web server, implements WSGI protocol, uwsgi agreement, http agreement.
uWSGI The main features are:
  ultra-fast performance
  low memory footprint
  multi-app management
  detailed logging (app can be used to analyze performance and bottlenecks)
  highly customizable (memory size limit, after serving a certain number of restarts, etc.)
  uWSGI server to achieve their own , we only need to specify the address of the application configuration file uwsgi based server uwsgi part of the agreement, uWSGI and application framework can WSGI application to communicate directly.
If these look above you do not understand, it does not matter, I use simple language to explain to you: uWSGI is a tool to help you manage the creation of the site. If the web is to establish your child, it is your child's personal nanny, your child's eating and sleeping it can have a way to track and maintain. This you get the picture.
  If you are still confused. A description of my bad language, you need to exercise. Another explanation is not worth it to you, the next second, do not waste time, Section II of the not for you.

Two usage scenarios

  uWSGI project aims to develop a full stack for building hosting service.
Use common API and style to achieve the common configuration application server (for a variety of programming languages and protocols), agents, process manager and supervisor.
Because of its pluggable architecture, it can be extended to support more platforms and languages.
Currently, you can write plug-ins using C, C ++ and Objective-C.
Versatile, high-performance, low resource use and reliability are the strengths of the project (and only follow the law).
Conceptual distinction:
  uWSGI is a Web server that implements the WSGI protocol, uwsgi, http and other protocols. Nginx role in HttpUwsgiModule uWSGI is exchanged with the server.
  Pay attention to WSGI / uwsgi / uWSGI distinguish between these three concepts.
  WSGI is a communication protocol.
  uwsgi protocol is a line instead of the communication protocol used in this uWSGI server data communication with other network servers.
  The uWSGI is achieved uwsgi and WSGI two protocols Web server.
uwsgi uWSGI server protocol is a proprietary protocol, which defines the type of transmitting information (type of information), before each uwsgi packet 4byte type described for the transmission of information, it is compared with WSGI are two things. So do not be confused.

Three installation methods

Here are a few common installation method:
a source installation:
wget  http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
the tar-latest.tar.gz at zxvf to uwsgi
CD 
the make
the sudo the make the install

2 mounted using python pip

If the foundation is not good students, it is recommended to use this simple and clear:
PIP install uwsgi

Four testing guidelines

  Given a python a file, such as: test.py
says:

/usr/bin/python3
def application(env, start_response):
start_response(‘200 OK’, [(‘Content-Type’,‘text/html’)])
return [b"This is XuSheng uWSGI test "]

  If you are using a python2, things behind the return is estimated to be about change, specifically how to change it to you, not difficult.
Next, start uWSGI to run an HTTP service sends a request to your SWGI applications.
Use the following command:
  

uwsgi --http :9090 --wsgi-file test.py

Then, if you can successfully run the information through the log view:

本人正常的log信息:
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 1418
your memory page size is 4096 bytes
detected max file descriptor number: 7168
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :9090 fd 4
spawned uWSGI http 1 (pid: 30744)
uwsgi socket 0 bound to TCP address 127.0.0.1:54389 (port auto-assigned) fd 3
Python version: 3.7.1 (default, Dec 14 2018, 13:28:58) [Clang 4.0.1 (tags/RELEASE_401/final)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x7ff902600e30
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72888 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint=’’) ready in 0 seconds on interpreter 0x7ff902600e30 pid: 30743 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 30743, cores: 1)

Then enter in your browser:
http://127.0.0.1:9090
view is correct
as follows:


  Thus, the basic end of the presentation, if you are an out energetic, doing nothing, sensitive and studious, good student. It can be seen below the index, something more than let you finish school.

In-depth documentation:

https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/

https://github.com/ictar/uwsgi-docs/blob/master/index.rst

https://www.jianshu.com/p/679dee0a4193 

Guess you like

Origin www.cnblogs.com/dylancao/p/11478441.html