wsgi

Linux-部署-Django

拟墨画扇 提交于 2021-02-20 17:21:27
Linux-部署-Django-项目过程与问题总结 优才网 2017-04-12 18:00 本篇主要用于记录部署 Django 项目所有踩过的坑。 最近学习 Django 框架开发,将项目部署到 Linux 服务器上时遇到了很多坑,在此整理一下以作备忘,同时希望对有需要的同学有所帮助。 从 0 开始,在 Linux 上部署 Django 项目共有如下几步: 1. 安装 Python3.5 2. 安装 Apache2.4 3. 安装 wsgi 4. 配置数据库和静态文件 5. 配置 Apache 6. 处理权限问题 下面一步步来进行详细介绍: 安装 Python3.5 1.安装编译环境 2. 下载编译 Python3.5 源码包 prefix 指明了 Python3.5 的安装目录,后面的 --enable-shared LDFLAGS="-Wl,-rpath=/usr/local/python3" 选项保证了可以正常使用共享库,否则在编译安装后可能会出现以下错误: 我自己在完成后执行 Python3.5 的命令时就遇到了。查找了很多的解决方案,上面这种在编译时进行LDFLAGS配置应该是最简洁有效的方式。 另外这个错误在使用wsgi时也可能会遇到,其官方文档还特地针对该问题作了【介绍】(http://modwsgi.readthedocs.io/en/develop/user

Linux学习笔记之Django项目部署(CentOS)----进阶篇

筅森魡賤 提交于 2021-02-19 05:03:37
一、引入   当我们开发好了一个Django项目之后是需要部署到服务器上的,这样才能正式使用这个项目。之前用了一个运行.sh文件的方法让项目得以在后台运行,其实随着学习的深入,这种方法其实是有点low的,下面介绍今天的新方法。 二、uwsgi   1.什么是uwsgi     项目的文件中有一个wsgi的文件,其实这就是生产环境中会用到的wsgi。     WSGI:Web服务器网关接口,英文为Python Web Server Gateway Interface,缩写为WSGI,是Python应用程序或框架和Web服务器之间的一种接口,被广泛接受。     uWSGI:实现了WSGI的所有接口,是一个快速、自我修复、开发人员和系统管理员友好的服务器(用C语言编写)。   2.安装uwsgi      pip install uwsgi   3.配置uwsgi.ini,在项目中新建文件uwsgi.ini,与manage.py文件同级,编写如下配置: [uwsgi] socket = 外网ip:端口(使用nginx连接时,使用socket) http = 外网ip:端口(直接做web服务器,使用http) chdir = 项目根目录 wsgi -file= 项目中wsgi.py文件的目录,相对于项目根目录 processes =4 threads =2 master = True

GAE don't see gunicorn, but it is already installed

拈花ヽ惹草 提交于 2021-02-18 10:23:09
问题 I am trying to deploy Django app with Google App Engine. My app.yaml file: # [START runtime] runtime: python api_version: 1 threadsafe: true env: flex entrypoint: gunicorn -b :$PORT wsgi runtime_config: python_version: 3.4 env_variables: CLOUDSQL_CONNECTION_NAME: ugram-mysql CLOUDSQL_USER: root handlers: - url: / script: wsgi.application # [END runtime] But when I run gcloud app deploy , app deploy is running (5 minutes), but I get an error: Updating service [default]...failed. ERROR: (gcloud

浅析uWSGI、uwsgi、wsgi

狂风中的少年 提交于 2021-02-13 22:38:06
WSGI协议 首先弄清下面几个概念: **WSGI:**全称是 Web Server Gateway Interface , WSGI 不是服务器, python 模块,框架, API 或者任何软件,只是一种规范,描述 web server 如何与 web application 通信的规范。 server 和 application 的规范在 PEP 3333 中有具体描述。要实现WSGI协议,必须同时实现web server和web application,当前运行在 WSGI 协议之上的 web 框架有 Bottle , Flask , Django 。 **uwsgi:**与 WSGI 一样是一种通信协议,是 uWSGI 服务器的独占协议,用于定义传输信息的类型( type of information ),每一个 uwsgi packet 前 4byte 为传输信息类型的描述,与WSGI协议是两种东西,据说该协议是 fcgi 协议的10倍快。 **uWSGI:**是一个 web 服务器,实现了 WSGI 协议、 uwsgi 协议、 http 协议等。 WSGI 协议主要包括 server 和 application 两部分: WSGI server 负责从客户端接收请求,将 request 转发给 application ,将 application 返回的

django之contenttype

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-12 05:37:27
1、contenttype:在django中将models.py文件的表结构写好后,通过makemigrations和migrate两条命令进行数据库迁移后,在数据库中会自动生成一个django_content_type表。 2、contenttype表的字段: id:id; app_label:新的model所对应的app应用名称; model:model的名称 即app应用中的model.py所对应的新增的表结构(类名)。 3、contenttype表的作用:每当我们创建了一个新的model并执行数据库迁移后,ContentType表中就会自动新增一条记录。比如我在应用api的models.py中创建表class Course(models.Model): pass。从数据库查看ContentType表会相应的增加一条数据 id:--, app_label:api, model:course。 4、应用场景:当出现一张表的数据要与多张表的数据关联的时候使用,   示例:现有两种课程(按不同标准收费的课程),每种课程对应多种收费方式,首先想到的是创建一张课程表,然后创建一张收费标准表让他们相关联,这种方法可行但存在缺陷; 表单创建: from django.db import models # 课程种类 轻课和学位课 class Course(models.Model): id

Dash deployed on apache server failing with “Dash object not callable”

China☆狼群 提交于 2021-02-11 12:32:30
问题 I'm trying to deploy a python dash app to my apache server. I followed the scant amount of information about this configuration that I could find (officials docs; this troubleshooting thread was a bit better). When I visit the website, the page returns a 500 Internal Server Error , which is described as "Dash object not callable" in the server error log. These are the config files: >> cat /var/www/html/wsgi/dashGAF.wsgi #!/usr/bin/python import sys sys.path.insert(0,"/home/ubuntu/dashboards/"

WSGI apps with python 2 and python 3 on the same server?

萝らか妹 提交于 2021-02-08 19:49:35
问题 I already have a web application in written in Python 2 that runs over WSGI (specifically, OpenERP web server). I would like to write a new web application that would run on the same server (Apache 2 on Ubuntu), but using WSGI and Python 3. The two applications would be on different ports. Is that possible? 回答1: No, it is not possible with mod_wsgi (see here: https://github.com/GrahamDumpleton/mod_wsgi/issues/21 and here: https://serverfault.com/questions/599859/multiple-python-versions-under

What is going on when I set app.wsgi_app = ProxyFix(app.wsgi_app) when running a Flask app on gunicorn?

三世轮回 提交于 2021-02-06 09:45:27
问题 I built a basic web app using Flask, and was able to run it from a virtual machine using its native http server. I quickly realized that with this set up, requests are blocking (I couldn't make concurrent requests for resources; any new request would wait until earlier requests had finished), and decided to try gunicorn to run the app to solve this problem. I followed the documentation, specifically running with this line: gunicorn -w 4 -b 127.0.0.1:4000 myproject:app However, it failed to

tornado vs wsgi(with gunicorn)

自闭症网瘾萝莉.ら 提交于 2021-02-05 12:40:53
问题 I read this about Tornado: On the other hand, if you already have a WSGI app and want to run it on a blazing fast tornado.httpserver.HTTPServer, wraps it with tornado.wsgi.WSGIContainer. But you need to be careful. Since your original application is not prepared for an asynchronous server, and will make a lot of IO/computation, it will block other requests while generating a response (further requests will be accepted and buffered but queued for later handling). And Guincorn says: 'a Python

What exactly is Werkzeug?

走远了吗. 提交于 2021-02-05 12:37:57
问题 From the official documentation: Werkzeug is a WSGI utility library for Python. However, when I run my Flask web application, I notice that the response header from the server contains: HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 13 Server: Werkzeug/0.11.9 Python/2.7.10 Date: Tue, 03 May 2016 12:50:08 GMT On the fourth line the server is mentioning a Werkzeug , but what exactly is Werkzeug , is it a web server like Apache ? 回答1: No, it is not a web server like