python django uwsgi nginx安装

已安装完成python/django的情况下安装

pip install uwsgi

cd /usr/share/nginx/html/

vim uwsgi.ini输入以下内容-------------------------------------------------------------

#uwsgi.ini file

[uwsgi]

# Django-related settings

# the base directory (full path)

chdir = /usr/share/nginx/html #manage.py所以目录

# Django‘s wsgi file

module = project2.wsgi:application #应用程序project2下的wsgi文件

# the virtualenv (full path)

#home = /path/to/virtualenv

# process-related settings

# master

master = true

# maximum number of worker processes

processes = 3

# the socket (use the full path to be safe)

#socket = /home/myself/myself.sock

socket = 127.0.0.1:8000 #以8000端口提供socket服务

# ... with appropriate permissions - may be needed

chmod-socket = 666

chown-socket = nginx:nginx

# clear environment on exit

vacuum = true

enable-threads = true

运行为cd /usr/share/nginx/html/

uwsgi --ini ./uwsgi.ini

yum install nginx

cd /etc/nginx/

vim nginx.conf输入以下内容-------------------------------------------------------------

upstream django {

server 127.0.0.1:8000;

}

location /static/ {

root /usr/share/nginx/html;

}

location / {

include uwsgi_params;

uwsgi_pass django;

}

cd /etc/systemd/system/ vim uwsgi.service

[Unit]

Description=uWSGI Emperor

After=syslog.target

[Service]

ExecStart=/usr/bin/uwsgi --emperor /usr/share/nginx/html

Restart=always

KillSignal=SIGQUIT

Type=notify

StandardError=syslog

NotifyAccess=all

[Install]

WantedBy=multi-user.target

setting.py中加入

STATIC_ROOT = ‘/usr/share/nginx/html/static/‘

python manage.py collectstatic

systemctl restart uwsgi.service

systemctl restart nginx.service

systemctl enable uwsgi.service

systemctl enable nginx.service

https://www.cnblogs.com/sumoning/p/7147755.html

原文地址:https://www.cnblogs.com/pyvm/p/10819293.html

时间: 2024-08-27 19:32:24

python django uwsgi nginx安装的相关文章

python django+uwsgi+nginx 搭建步骤(血一般的教训)

安装Django 没有pip的童鞋可以看http://blog.csdn.net/imphp/article/details/38228619安装python包管理工具pip 先在 https://pypi.python.org/ 上 搜索Django,排在第一的那个就是我们要安装的主要框架Django啦- 点进去可以查找一些相关文档,虽然全部是鸟语花香,不过有翻译.百度.炕忙,就算是菜鸟也成英国鸟了. Django 的官网文档 https://docs.djangoproject.com/en

python django uwsgi nginx   实例

实例:192.168.200.133 1.安装django wget  https://www.djangoproject.com/download/1.7.11/tarball/ 1.3.安装 cd Django-1.x.y sudo python setup.py install 1.4.创建  django-admin.py startproject testdj 1.5.启动测试 cd testdj # 切换到我们创建的项目 python manage.py runserver 2.安装

Django+uwsgi+Nginx安装部署

安装 安装Nginx Nginx是最流行的高性能HTTP服务器. wget http://nginx.org/download/nginx-1.10.1.tar.gz tar -zxvf nginx-1.10.1.tar.gz cd nginx-1.10.1 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module make && make install 安装MySQL-python MySQL-python

python django+uwsgi+nginx

概念: WSGI,全称 Web Server Gateway Interface,或者 Python Web Server Gateway Interface, 是为 Python 语言定义的 Web 服务器和 Web 应用程序或框架之间的一种简单而通用的接口. 自从 WSGI 被开发出来以后,许多其它语言中也出现了类似接口.可以理解为一个标准和规范. 很多框架都自带了 WSGI server ,比如 Flask,webpy,Django.CherryPy等等.当然性能都不好,自带的 web s

Django + Uwsgi + Nginx 的生产环境部署

使用runserver可以使我们的django项目很便捷的在本地运行起来,但这只能在局域网内访问,如果在生产环境部署django,就要多考虑一些问题了.比如静态文件处理,安全,效率等等,本篇文章总结归纳了一下基于uwsgi+Nginx下django项目生产环境的部署 准备条件: 1.确保有一个能够用runserver正常启动的django项目 2.项目已上传到linux 3.linux上已部署好python环境,且已安装好项目所需的模块 安装uwsgi uwsgi是python的一个模块,安装u

Django + Uwsgi + Nginx 实现生产环境部署

一.如何在生产上部署Django? Django的部署可以有很多方式,采用nginx+uwsgi的方式是其中比较常见的一种方式. 二.uwsgi介绍 uWSGI是一个Web服务器,它实现了WSGI协议.uwsgi.http等协议.Nginx中HttpUwsgiModule的作用是与uWSGI服务器进行交换. 要注意 WSGI / uwsgi / uWSGI 这三个概念的区分. WSGI是一种Web服务器网关接口.它是一个Web服务器(如nginx,uWSGI等服务器)与web应用(如用Flask

Django+uWsgi+nginx部署

一.环境 操作系统:Ubuntu 14.04 64位 python:2.7.6 Django:1.8.2 项目源码:https://github.com/youchuancong/django.git 部署方式:Django+uWsgi+nginx 二.部署 1.Django安装 官网:https://www.djangoproject.com/ 安装 wget https://www.djangoproject.com/m/releases/1.8/Django-1.8.2.tar.gz ta

Django+uWSGI+Nginx 部署网站

Django 1.11设置 保证Django在本地调试没有问题: 当然这是前提^_^ 收集静态文件至指定文件夹 Django静态文件设置具体参考:https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/ 在myproject/settings.py中设置静态文件STATIC_URL和STATIC_ROOT设置: 如: STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE

[linux]centos7.4部署django+Uwsgi+Nginx

前言:我已经写了几个接口用来部署在服务器上的,首先选择django+Uwsgi+Nginx因为配置简单,比较符合python的简单操作功能强大的特点 然后对于django的一些版本在之前的文章写了 参考:https://www.cnblogs.com/Jack-cx/p/9351633.html  根据版本,服务器pip3 install xxx 安装下 我的django项目大概结构: TestWebApi ----TestWebApi ----Apiso(创建的应用) ----manage.p