uwsgi

python+nginx+uwsgi部署云主机遇到的问题

主宰稳场 提交于 2019-12-01 14:51:51
问题后期会有次序的整理,目前整理一小部分 1.部署之后出现403问题。 403权限问题的修改: (1)打开nginx.conf文件 vim /etc/nginx/nginx.conf (2)按键盘“i”进入编辑模式,修改第一行为 user root; (3)按键盘“ esc ”退出键,输入 :wq ,保存并推出。 (4)查看80端口占用pid值 lsof -i tcp:80 (5)杀死pid=14012的进程 kill 14012 (6)启动nginx sudo /usr/sbin/nginx 查看页面是否显示正常 2.uwsgi的理解及简单使用? uwsgi 中文文档: http://uwsgi-docs-cn.readthedocs.io/zh_CN/latest/WSGIquickstart.html (1)简单运用-利用文件启动 新建uwsgitest.py的文件(python3+写法) def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"] 放置在服务器某个目录下 在该目录运行 uwsgi --http :9090 --wsgi-file uwsgitest.py 可以看到打出的文字

Error building uwsgi with pip in virtual environment

假装没事ソ 提交于 2019-12-01 14:47:08
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/setup.py) egg_info for package uwsgi Installing collected packages: uwsgi Running setup.py install for

Nginx与uWSGI交互

廉价感情. 提交于 2019-12-01 12:06:12
1. 更改uwsgi的配置文件uwsgi.ini [uwsgi] ... #使用nginx连接时, 监控地址 socket=127.0.0.1:8080 #直接做web服务器时, 所监控地址 #http=127.0.0.1:8080 2. 在nginx配置文件中的路由模块添加uwsgi支持. sudo vim /usr/local/nginx/conf/nginx.conf 更改server模块. server { listen 80; server_name localhost; location / { include uwsgi_params; uwsgi_pass localhost:8080; } nginx配置全文: 1 worker_processes 1; 2 events { 3 worker_connections 1024; 4 } 5 http { 6 include mime.types; 7 default_type application/octet-stream; 8 sendfile on; 9 keepalive_timeout 65; 10 11 server { 12 listen 80; 13 server_name localhost; 14 15 location / { 16 include uwsgi_params; 17

uwsgi相关配置

拜拜、爱过 提交于 2019-12-01 12:05:45
1. 安装 pip install uwsgi 2. 配置文件 更改Django配置文件 settings , 备上线 DEBUG = False ALLOWED_HOSTS = ['*'] 新建uwsgi.ini配置文件: [uwsgi] #使用nginx连接时, 监控地址 #socket=127.0.0.1:8080 #直接做web服务器时, 所监控地址 http=127.0.0.1:8080 #项目所在目录 chdir=/home/jrri/Desktop/myproject #项目中wsgi.py文件的目录,相对于项目目录 wsgi-file=myproject/wsgi.py # 工作进程线程 processes=4 threads=2 # 是否需要主进程 master=True # 保存主进程pid文件 pidfile=uwsgi.pid # 设置项目为守护运行, 保存运行日志文件所在位置 daemonize=uwsgi.log # 设置虚拟环境所在位置 virtualenv=/Users/smart/.virtualenvs/myproject 3. uwsgi服务器的启动关闭. 启动: uwsgi --ini uwsgi的配置文件所在路径 uwsgi --ini uwsgi.ini 关闭: uwsgi --stop uwsgi.pid文件所在路径 uwsgi –

Python Web部署方式总结

廉价感情. 提交于 2019-12-01 11:02:58
学过PHP的都了解,php的正式环境部署非常简单,改几个文件就OK,用FastCgi方式也是分分钟的事情。相比起来,Python在web应 用上的部署就繁杂的多,主要是工具繁多,主流服务器支持不足,在了解Python的生产环境部署方式之前,先明确一些概念!很重要! 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脚本工作流程

How can I redirect HTTP to HTTPS with uWSGI internal routing?

徘徊边缘 提交于 2019-12-01 10:33:47
I have deployed a WSGI application with uWSGI, but I am not using NGINX . How can I use uWSGI's internal routing to redirect http requests to https ? I have tried uwsgi --route-uri="^http:\/\/(.+)$ redirect-permanent:https://\$1" but get an error from uWSGI: unrecognized option '--route-uri=^https:\/\/(.+)$ redirect-permanent:https://\$1' to redirect http to https, use following config: [uwsgi] ; privileged port can only be opened as shared socket shared-socket = 0.0.0.0:80 shared-socket = 0.0.0.0:443 ;enable redirect to https http-to-https = =0 ; enable https, spdy is optional https2 = addr=

Ubuntu下部署Django项目

杀马特。学长 韩版系。学妹 提交于 2019-12-01 10:05:19
1.首先要进入本地环境把项目所需要的环境导出来 pip freeze >requirements.txt 2.安装python3.6.8版本 3.安装得到的requirements.txt 命令:pip3 install -r requirements.txt 全部安装 如果遇到HTTPConnectionPool(host=''xx.xx.xx.xx', port=xx): Max retries exceeded with url: (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000237EE44EF98>: Failed to establish a new connection: [WinError 10060]错误 处理方法:https://www.cnblogs.com/erhangboke/p/11663057.html 4.修改项目的settings文件 DEBUG = False(线上的项目一定要修改成False) ALLOWED_HOSTS = ["*"] 5.在django的settings文件中,添加下面一行内容: STATIC_ROOT = os.path.join(BASE_DIR, "static/") 7.配置路由(貌似不是必须)

阿里云:uwsgi--配置出错 bind(): Address already in use [core/socket.c line 769]

戏子无情 提交于 2019-12-01 10:03:34
按照网上配置nginx+uwsgi+django的文章,nginx启动成功,django启动也成功,单独用uwsgi --http :8000 命令启动uwsgi也成功。使用uwsgi --socket :8000就失败。搜了好久好久,才解决了,现将问题记录一下。用阿里云的服务器会出现这个问题。 出现上图错误:bind(): Address already in use [core/socket.c line 769] 经排查后,发现:阿里云的网路问题 解决方案: uwsgi配置里的socket这里不能写127.0.0.1,要写阿里的内网。就这里改一下,就可以了。 nginx这里配公网ip。 再次启动Nginx+uwsgi+Django,成功访问。 来源: https://www.cnblogs.com/gengyufei/p/11678141.html

Django Nginx+uwsgi 安装配置

混江龙づ霸主 提交于 2019-12-01 10:02:16
Django Nginx+uwsgi 安装配置 在前面的章节中我们使用 python manage.py runserver 来运行服务器。这只适用测试环境中使用。 正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache, Nginx, lighttpd等,本文将以 Nginx 为例。 你也可以直接参考: Python uwsgi 安装配置 安装基础开发包 Centos 下安装步骤如下: yum groupinstall "Development tools" yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel CentOS 自带 Python 2.4.3,但我们可以再安装Python2.7.5: cd ~ wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 tar xvf Python-2.7.5.tar.bz2 cd Python-2.7.5 ./configure --prefix=/usr/local make && make altinstall 安装Python包管理 easy_install 包 https:/

WSGI——python-Web框架基础

爷,独闯天下 提交于 2019-12-01 09:56:46
1. 简介 WSGI ​ WSGI :web服务器网关接口,这是python中定义的一个网关协议,规定了Web Server如何跟应用程序交互。可以理解为一个web应用的容器,通过它可以启动应用,进而提供HTTP服务。 ​ 它最主要的目的是保证在Python中所有的Web Server程序或者说Gateway程序,能够通过统一的协议跟Web框架或者说Web应用进行交互。 uWSGI ​ uWGSI :是一个web服务器,或者wsgi server服务器,他的任务就是接受用户请求,由于用户请求是通过网络发过来的,其中用户到服务器端之间用的是http协议,所以我们uWSGI要想接受并且正确解出相关信息,我们就需要uWSGI实现http协议,没错,uWSGI里面就实现了http协议。所以现在我们uWSGI能准确接受到用户请求,并且读出信息。现在我们的uWSGI服务器需要把信息发给Django,我们就需要用到WSGI协议,刚好uWSGI实现了WSGI协议,所以。uWSGI把接收到的信息作一次简单封装传递给Django,Django接收到信息后,再经过一层层的中间件,于是,对信息作进一步处理,最后匹配url,传递给相应的视图函数,视图函数做逻辑处理......后面的就不叙述了,然后将处理后的数据通过中间件一层层返回,到达Djagno最外层,然后