uwsgi

python-django框架-电商项目-项目部署_20191127

十年热恋 提交于 2019-12-05 19:37:37
python-django框架-电商项目-项目部署: uwsgi作为web服务器: 在pycharm中启动项目:使用python manage.py runserver 这个runserver是django提供的开发的时候的web服务器,这个服务器只在开发的时候使用,部署的时候不会,部署的时候使用uwsgi, uwsgi 这是一个遵循wsgi协议的web服务器, ################### 报错 ########################### 安装:pip install uwsgi,这个转入自己的虚拟环境, 报错:AttributeError: module 'os' has no attribute 'uname' 解决: 定位到uwsgiconfig.py文件中,首先import platform后,将os.unam()都改为platform.uname()即可。 os.uname()是不支持windows系统的。platform模块是支持任何系统。 2.下载uwsgi离线安装 https://pypi.python.org/pypi/uWSGI/ 解压后,进入目录下 python setup.py install 报错:Exception: you need a C compiler to builduWSGI 安装了MinGW的c编译器,但是还是不行,

nginx+uwsgi+django, there seems to be some strange cache in uwsgi, help me

泄露秘密 提交于 2019-12-05 18:47:40
This is uwsgi config: [uwsgi] uid = 500 listen=200 master = true profiler = true processes = 8 logdate = true socket = 127.0.0.1:8000 module = www.wsgi pythonpath = /root/www/ pythonpath = /root/www/www pidfile = /root/www/www.pid daemonize = /root/www/www.log enable-threads = true memory-report = true limit-as = 6048 This is Nginx config: server{ listen 80; server_name 119.254.35.221; location / { uwsgi_pass 127.0.0.1:8000; include uwsgi_params; } } The django works ok, but modifed pages can't be seen unless i restart uwsgi.(what's more, as i config 8 worker process, i can see the modified

Nginx的负载均衡和项目部署

 ̄綄美尐妖づ 提交于 2019-12-05 17:41:40
nginx的作用 Nginx是一款自由的、开源的、高性能的HTTP服务器和反向代理服务器;同时也是一个IMAP、POP3、SMTP代理服务器;Nginx可以作为一个HTTP服务器进行网站的发布处理,另外Nginx可以作为反向代理进行负载均衡的实现。 Web服务器,直接面向用户,往往要承载大量并发请求,单台服务器难以负荷,我使用多台WEB服务器组成 集群,前端使用Nginx负载均衡,将请求分散的打到我们的后端服务器集群中, 实现负载的分发。那么会大大提升系统的吞吐率、请求性能、高容灾 Nginx要实现负载均衡需要用到proxy_pass代理模块配置 Nginx负载均衡与Nginx代理不同地方在于 Nginx代理仅代理一台服务器,而Nginx负载均衡则是将客户端请求代理转发至一组upstream虚拟服务池 Nginx可以配置代理多台服务器,当一台服务器宕机之后,仍能保持系统可用。 upstream配置 在nginx.conf > http 区域中 upstream django { server 10.0.0.10:8000; server 10.0.0.11:9000; } 在nginx.conf > http 区域 > server区域 > location配置中 添加proxy_pass location / { root html; index index.html index

用uWSGI和Nginx部署Flask项目

懵懂的女人 提交于 2019-12-05 17:07:59
概况 (虚拟环境已经搭好,不做演示) 在开发过程中,我们一般直接用Python命令直接运行Flask程序。这样的运行只适合我们开发,方便我们调试。一旦程序部署到线上,这样运行的Flask程序性能会比较低。可以采用uWSGI+Nginx进行部署。 uWSGI 在部署之前,我们得先了解几个概念 wsgi web应用程序之间的接口。它的作用就像是桥梁,连接在web服务器和web应用框架之间。 uwsgi 是一种传输协议,用于定义传输信息的类型。 uWSGI 是实现了uwsgi协议WSGI的web服务器。 部署 首先准备一个flask程序,名字run.py(自己的项目主目录app.py的名字) from flask import Flask ​ app = Flask(__name__) ​ @app.route("/") def index(): return '部署' ​ if __name__ == '__main__': app.run() 安装uWSGI pip install uwsgi 在项目的目录创建一个uwsgi的配置文件 [uwsgi] #配合nginx使用 socket = 127.0.0.1:8000 #项目路径 /自己项目路径/flask_test chdir = 自己项目路径 #wsgi文件 run就是flask启动文件去掉后缀名 app是run

使用docker-compose+nginx+uwsgi+django部署项目

99封情书 提交于 2019-12-05 16:39:33
(1)centos上下载docker + docker-compose (2)基础目录 (3)首先创建一个纯净的python+django+uwsgi的镜像,便于后期使用(也可不用创建,后期docker-compose的时候再创建python镜像,这里我们先创建,后期直接把项目放进去,不用每次都下载环境) 创建python+django+uwsgi的纯净镜像,命名镜像名为django: #Dockerfile 这个dockrfile不是基础目录中的Dockerfile,需要在其他目录中创建 FROM python RUN mkdir /code WORKDIR /code ADD requirements.txt . /code RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt RUN rm -f requirements.txt #requirements.txt django==2.2.2 psycopg2 uwsgi (4)基础目录中的Dockerfile #使用刚刚创建的基础镜像django FROM django WORKDIR /code RUN mkdir hello #创建项目目录 ADD . /code/hello (5)创建uwsgi配置文件

nginx serving Django in a subdirectory through uWSGI

人盡茶涼 提交于 2019-12-05 15:39:37
问题 I have already gone through some previous threads: How do I set subdirectory in nginx with Django how to deploy django under a suburl behind nginx Serving flask app on subdirectory nginx + uwsgi The basic lesson is that you should only need to configure your site(s-available) to achieve this. I have now tried various permutations of server { listen 80; server_name www.example.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /path/to/project; }

Docker容器化部署Python应用

家住魔仙堡 提交于 2019-12-05 14:45:10
1. 简介 Docker 是目前主流IT公司广泛接受和使用的,用于构建、管理和保护它们应用程序的工具。 容器,例如Docker允许开发人员在单个操作系统上隔离和运行多个应用程序,而不是为服务器上的每个应用程序专用一个虚拟机。使用容器更轻量级,可以降低成本、更好地使用资源和发挥更高的性能。 本文将使用Flask开发一个简单的Python web应用程序,并为“容器化”做好准备。然后创建一个Docker映像,并将其部署到测试和生产环境中。 注意: 请确保机器上已安装Docker,如果没有请参考 Docker官方安装教程 。 2. Docker介绍 Docker是一种工具,它使开发人员能够交付他们的应用程序(以及库或其他依赖项),确保他们可以使用正确的配置运行,而不受部署环境影响。 这是通过将应用程序隔离在单独的容器中来实现的,这些应用程序虽然被容器分隔开,但是却可以共享操作系统和其他资源。 Docker包含两部分: Docker Engine — 应用打包工具,用于封装应用程序。 Docker Hub — 用于管理云上容器应用程序的工具。 3.为何选择容器 了解容器的重要性和实用性非常重要,虽然它和直接将应用部署到服务器没有多大区别,但是当涉及到比较复杂的且相当吃资源的应用,尤其是多个应用部署在同一台服务器,或是同一应用要部署到多台服务器时。容器就变得非常有用。 在容器之前,这是通过

安装 uwsgi报错解决

人走茶凉 提交于 2019-12-05 13:46:41
背景: 安装 uwsgi时报错如下,查阅相关资料说是 python-devel的问题,于是安装之后python-devel后问题解决 报错如下: 1 (venv) [xxxxxxxx]# pip install uwsgi 2 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support 3 Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ 4 Collecting uwsgi 5 Downloading http://mirrors.aliyun.com/pypi/packages/e7

使用uwsgi+nginx部署项目

依然范特西╮ 提交于 2019-12-05 11:40:20
Uwsgi :部署 web 应用程序 Nginx :反向代理,静态服务器 1. 修改 uwsgi 配置文件》 nginx 反向代理 [nginx 接收请求 - 》传递 - 》[ uwsgi] http=.. -- 》 socket=.. 为了保证项目的访问安全, ip 地址变为本机地址 [uwsgi] Socket=127.0.0.1:8000 Chdir=.. Wsgi-file=.. Master=.. Process=.. #static-map=.. 注释掉,静态文件有 nginx 代理 2.确认是否安装 nginx 命令行安装: apt-get install nginx 源代码安装: wget http://nginx.org/download/nginx-1.6.2.tar.gz - 》解压 tar xzvf ...tar.gz - 》 make & make install 修改 nginx 配置文件 cd /etc/nginx/nginx.conf 添加虚拟服务器配置 [server] 添加反向代理路由配置 [location - uwsgi_pass] 添加静态文件服务器路由配置 [location - alias] 重启 nginx nginx 对静态文件的处理优于 uwsgi Uwsgi 对动态文件的处理优于 nginx 在 http 中添加 server

使用uwsgi部署项目?

冷暖自知 提交于 2019-12-05 11:38:50
方式1 : 这种方式虽然比较方便,但是启动操作比较繁琐,每次都不能关闭窗口 安装 uwsgi : pip3 install uwsgi 上传项目,部署 web app 创建数据库,同步数据 运行 django 项目: uwsgi --http=192.168.132.128:8000 --file=pfeiliu/wsgi.py 浏览器输入 http://192.168.132.128:8000 即可访问,但是无法加载静态文件 收集静态文件? Manage.py 同级目录新建 static_file 文件夹,在 setting.py 中配置 STATIC_ROOT='/home/tarena/ 桌面 /django-pfeiliu/pfeiliu/static-file' 命令行输入 python3 manage.py collectstatic ,即可在 static_file 中收集静态文件 运行 django 项目,指定 static : uwsgi --http=192.168.132.128:8000 --file=pfeiliu/wsgi.py --stat-map=/static=static-file 此时即可网页中即可加载静态文件 方式2: 命令行后台执行,开头加上 nohup 结尾加上 & 符号 nohup uwsgi --http=192.168.132