uwsgi

django -- uwsgi+nginx部署

混江龙づ霸主 提交于 2019-12-20 00:18:25
一、 安装nginx How To Install Nginx on CentOS 7 添加epel扩展仓 sudo yum install epel-release 安装Nginx yum install nginx 开启Nginx sudo systemctl start nginx 如果防火墙拦截,可用下面的命令 sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload 浏览器打开 http://your_ip/ , 出现Welcome to nginx!说明安装成功 开机启动项 systemclt enable nginx 服务器默认的根目录 /usr/share/nginx/html , 服务器配置目录 /etc/nginx/conf.d/ ,文件要以 .conf 结尾. 全局配置文件 /etc/nginx/nginx.conf 二、安装 uwsgi pip install uwsgi # 测试uwsgi 如:./Projects/Project/wsgi.py cd Projects uwsgi --http :8000 -

【转】网关协议学习:CGI、FastCGI、WSGI、uWSGI

*爱你&永不变心* 提交于 2019-12-19 18:45:11
一直对这四者的概念和区别很模糊,现在就特意梳理一下它们的关系与区别。 CGI CGI即通用网关接口(Common Gateway Interface),是外部应用程序(CGI程序)与Web服务器之间的接口标准,是在CGI程序和Web服务器之间传递信息的规程。CGI规范允许 Web服务器执行外部程序,并将它们的输出发送给Web浏览器,CGI将Web的一组简单的静态超媒体文档变成一个完整的新的交互式媒体。通俗的讲CGI 就像是一座桥,把网页和WEB服务器中的执行程序连接起来,它把HTML接收的指令传递给服务器的执行程序,再把服务器执行程序的结果返还给HTML页。 CGI 的跨平台性能极佳,几乎可以在任何操作系统上实现。 CGI方式在遇到连接请求(用户请求)先要创建cgi的子进程,激活一个CGI进程,然后处理请求,处理完后结束这个子进程。这就是fork- and-execute模式。所以用cgi方式的服务器有多少连接请求就会有多少cgi子进程,子进程反复加载是cgi性能低下的主要原因。当用户请求数 量非常多时,会大量挤占系统的资源如内存,CPU时间等,造成效能低下。 CGI脚本工作流程: 浏览器通过HTML表单或超链接请求指向一个CGI应用程序的URL。 服务器收发到请求。 服务器执行所指定的CGI应用程序。 CGI应用程序执行所需要的操作,通常是基于浏览者输入的内容。

Error building uwsgi with pip in virtual environment

梦想与她 提交于 2019-12-19 12:01:26
问题 I am getting errors when I try to install uwsgi in my virtual environment in my Centos VPS. Ultimately, I cannot install uwsgi. I am using : pip install uwsgi and also : pathtovirtualenv/bin/pip install uwsgi I get the following output on the terminal: wwwthecanonworks@thecanonworks.com [~]# ~/thecanonworks/env/bin/pip install uwsgi Downloading/unpacking uwsgi Downloading uwsgi-2.0.8.tar.gz (775kB): 775kB downloaded Running setup.py (path:/home/wwwthecanonworks/thecanonworks/env/build/uwsgi

Flask, nginx, and uwsgi

99封情书 提交于 2019-12-19 09:02:03
问题 My flask app looks like this... myapp.py from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run('0.0.0.0') My nginx setup server { root /home/admin.jeremylspencer.com; server_name admin.jeremylspencer.com; location / { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; uwsgi_pass unix:/tmp/uwsgi.sock; } #error_page 404 /404.html; #error_page 500 502 503 504 /50x.html; location = /50x

nginx + uwsgi + flask - disabling custom error pages

那年仲夏 提交于 2019-12-19 05:42:47
问题 Is it possible to disable nginx's custom error pages - if I may call them that - to display my framework's exception pages? I can't really see my werkzeug debugger tool rendered in html... UPDATE OK, I got to make a very very simple flask application to work and I'll post the bits: /home/my_user/.virtualenvs/nginx-test/etc/nginx.conf worker_processes 1; events { worker_connections 1024; } http { server { listen 5000; server_name localhost; access_log /home/my_user/.virtualenvs/nginx-test/lib

nginx custom error page 502 with css and image files

﹥>﹥吖頭↗ 提交于 2019-12-19 02:25:47
问题 I'm trying to add a custom error page for 503. what I did is. adding below lines to server conf in nginx.conf file. error_page 500 502 503 504 /50x.html; location = /50x.html { root /home/username/sites/myProject/current/errorPages; internal; } It displays the custom page when uwsgi is down, however this doesn't show any images. I tried many different configurations I can think o, but no luck. Does anybody know how I can display image file and enable css for a custom error page? I put my

How to enable uWSGI logging to a file?

夙愿已清 提交于 2019-12-18 19:05:20
问题 I have just installed my first uWSGI server on EC2 Ubuntu 14.04 LTS, using the following configuration: [uwsgi] http-socket = :9001 plugin = python wsgi-file = foo.wsgi chdir = /home/bar process = 3 The uWSGI container works fine, but has no logging. Following the manual, I've added the following: logger = file:/tmp/errlog But restarting (using sudo service uwsgi restart ) did not work - the server would not start with this configuration. Any idea what's missing from my ini configuration? 回答1

'ascii' codec can't decode error when use pip to install uwsgi

╄→гoц情女王★ 提交于 2019-12-18 10:55:31
问题 I am setting up uwsgi following this tutorial: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html. I run pip install uwsgi within virtualenv, but get the problem as follows: Command /home/timyitong/superleagues/bin/python -c "import setuptools;__file__='/home/timyitong/superleagues/build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Z9h8Jn-record/install-record.txt --single-version-externally

Websockets in Flask

女生的网名这么多〃 提交于 2019-12-18 10:05:37
问题 I'm currently researching websocket support in Python and am a bit confused with the offerings. On one hand it's possible to use Flask + gevent. On the other hand, uwsgi has socket support and at last there is an extension that bundles both uwsgi and gevent. What's the problem with implementing websockets with only one of these? What do I win by mixing them? Changing the question What does adding gevent do that threaded uwsgi won't? 回答1: In regular HTTP requests the connections between client

uwsgi参数详解

自古美人都是妖i 提交于 2019-12-18 07:41:20
master = true #启动主进程,来管理其他进程,其它的uwsgi进程都是这个master进程的子进程,如果kill这个master进程,相当于重启所有的uwsgi进程。 chdir = /web/www/mysite #在app加载前切换到当前目录, 指定运行目录 module = mysite.wsgi # 加载一个WSGI模块,这里加载mysite/wsgi.py这个模块 py-autoreload=1 #监控python模块mtime来触发重载 (只在开发时使用) lazy-apps=true #在每个worker而不是master中加载应用 socket = /test/myapp.sock #指定socket文件,也可以指定为127.0.0.1:9000,这样就会监听到网络套接字 processes = 2 #启动2个工作进程,生成指定数目的worker/进程 buffer-size = 32768 #设置用于uwsgi包解析的内部缓存区大小为64k。默认是4k。 daemonize = /var/log/myapp_uwsgi.log # 使进程在后台运行,并将日志打到指定的日志文件或者udp服务器 log-maxsize = 5000000 #设置最大日志文件大小 disable-logging = true #禁用请求日志记录 vacuum = true