Python High Performance Network Framework (i) __python

Source: Internet
Author: User
Linux+nginx+uwsgi

1. Install Nginx

sudo apt install nginx
sudo service nginx start

2. Overview of Nginx configuration, similar to Tomcat

# Program Files:/usr/sbin/nginx ############################################################################ # Global configuration file:/etc/  nginx/nginx.conf user www-data;  #定义运行nginx的用户 worker_processes Auto;
#进程数 Pid/run/nginx.pid; Worker_rlimit_nofile 65535;   #每个nginx进程可以打开的最大文件数 Events {worker_connections 768; #每个nginx进程允许的最大客户端连接数 multi_accept off;    #在创建一个新连接后调用accept () to accept as many connections as possible} HTTP {# # Basic Settings # # sendfile on;  #是否允许文件上传 Tcp_nopush on; #防止网络阻塞 Tcp_nodelay on;   #防止网络阻塞 Keepalive_timeout 65;   #允许的客户端长连接秒数 types_hash_max_size 2048;
    #散列表大小, occupy space and route speed are positively correlated # server_tokens off;
    # Server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
    Include/etc/nginx/mime.types;
    Default_type Application/octet-stream; # # SSL Settings # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    # dropping SSLv3, Ref:poodle ssl_prefer_server_ciphers on;
    # # # Logging Settings # # Access_log/var/log/nginx/access.log; Error_Log/var/log/nginx/error.log;
    # # gzip Settings # gzip on;
    Gzip_disable "Msie6";
    # gzip_vary on;
    # gzip_proxied any;
    # Gzip_comp_level 6;
    # gzip_buffers 8k;
    # Gzip_http_version 1.1; # gzip_types Text/plain text/css application/json application/javascript text/xml application/xml Application/xml+rss
    Text/javascript;
    # # Virtual Host configs # # #加载站点配置文件 include/etc/nginx/conf.d/*.conf;
include/etc/nginx/sites-enabled/*;   } #mail {# # Authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # #
# auth_http localhost/auth.php;
# # Pop3_capabilities "Top" "USER";
# # Imap_capabilities "IMAP4rev1" "Uidplus";       # server {# Listen localhost:110 # protocol POP3; # Proxy on; #} # # server {#
Listen localhost:143;
# protocol IMAP;
# Proxy on; #   }
#}
##################################################################################### # Access log file:/var/log/nginx/access.log ############################################ ######################################### # error log file:/var/log/nginx/error.log ##################################### ################################################ # Site configuration file:/etc/nginx/sites-enabled/default # # You should look at the  Following URL ' grasp a solid understanding # of Nginx configuration files in order to fully unleash the power
of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you'll want to move this file somewhere, and start with a clean # file but keep this around for reference.
Or just disable in sites-enabled.
# Please see/usr/share/doc/nginx-doc/examples/for more detailed examples.
    # # # Default Server Configuration # server {Listen default_server;
    Listen [::]:80 default_server;
  # SSL Configuration # # Listen 443 SSL default_server;  # Listen [::]:443 SSL Default_server;
    # # Note:you should disable gzip for SSL traffic.
    # see:https://bugs.debian.org/773332 # Read up in ssl_ciphers to ensure a secure configuration.  # see:https://bugs.debian.org/765782 # Self signed certs generated by Ssl-cert package # Don ' t use them
    In a production server!
    # # include snippets/snakeoil.conf; root/usr/share/nginx/html; #配置http根目录 # ADD index.php to the ' list if you are using PHP index index.html index.htm;
    #配置根目录中的默认页面 server_name localhost;
    location/user/{# Attempt to serve request as file, then Proxy_pass http://127.0.0.1:8080;
    # as Directory, then fall back to displaying a 404.
    Error_page 404/404.html; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {# include Snippe
    ts/fastcgi-php.conf; # # # with php7.0-cgi alone: # Fastcgi_pass 127.0.0.1: 9000;
    # with PHP7.0-FPM: # Fastcgi_pass Unix:/run/php/php7.0-fpm.sock; #} # Deny access to. htaccess files, if the Apache ' s document Root # concurs with Nginx ' s one # #location ~/
    \.ht {# deny all; #} # Virtual Host configuration for example.com # ' can move ' to a different file under Sites-available/and sym
Link that # to sites-enabled/to enable it. # #server {# listen # listen [::]:80; # server_name example.com; # root/var/www/example.com; # index I
ndex.html; # # location/{# Try_files $uri $uri/= 404; #} #}

3.UWSGI Configuration:
If you are running UWSGI, you can try running the following command to install the compile
Pip Install Uwsgi-i–no-cache-dir
If it's still not working, then run this command again.
sudo apt-get install libpcre3 Libpcre3-dev

4. Problems that may be encountered
Configure a script to return to the front
Uwsgi-s: 9090-w webapp.py
Add parameters if invalid block size is displayed
Uwsgi-b 8192
or modify the Uwsgi startup configuration file, such as Uwsgi.ini, to add the following configuration:
Buffer-size = 8192

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.