django -- uwsgi+nginx部署
一、 安装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 --module Project.wsgi
# or
uwsgi --http :8000 --file Project/wsgi.py
uwsgi 常用命令
uwsgi --chdir=/path/to/your/project \
--module=mysite.wsgi:application \
--env DJANGO_SETTINGS_MODULE=mysite.settings \
--master --pidfile=/tmp/project-master.pid \
--socket=127.0.0.1:49152 \ # can also be a file
--processes=5 \ # number of worker processes
--uid=1000 --gid=2000 \ # if root, uwsgi can drop privileges
--harakiri=20 \ # respawn processes taking more than 20 seconds
--max-requests=5000 \ # respawn processes after serving 5000 requests
--vacuum \ # clear environment on exit
--home=/path/to/virtual/env \ # optional path to a virtualenv
--daemonize=/var/log/uwsgi/yourproject.log # background the process
三、配置nginx
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8000; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /path/to/your/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /path/to/your/mysite/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /path/to/your/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
加入nginx项目配置
sudo ln -s 你的目录/Mxonline/conf/nginx/uc_nginx.conf /etc/nginx/conf.d/
重启nginx
systemctl restart nginx
四、通过配置文件启动uwsgi
新建uwsgi.ini 配置文件, 内容如下:
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /path/to/Projects
# Django's wsgi file
module = Project.wsgi
# the virtualenv (full path)
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = 127.0.0.1:8000
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
virtualenv = .virtualenvs_dirs/venv_py
logto = /tmp/mylog.log
注:
chdir: 表示需要操作的目录,也就是项目的目录
module: wsgi文件的路径
processes: 进程数
virtualenv:虚拟环境的目录
参考: centos7 下通过nginx+uwsgi部署django应用
参考: Django + Uwsgi + Nginx 的生产环境部署
django -- uwsgi+nginx部署的更多相关文章
- virtualvenv+django+uWSGI+nginx 部署
原创博文 转载请注明出处! 1. virtualvenv 2. django 3. uWSGI 4. nginx 5. 踩坑记录 1. virtualvenv virtualvenv install ...
- django+uwsgi+nginx部署(非常详细)
django+uwsgi+nginx部署 1.介绍: 在网上看了很多教程,但自己部署了很久都没有成功,这篇博文记录自己所踩过得坑. 2.环境: Ubuntu 16.04.1 LTS (GNU/Linu ...
- Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx)
Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx) 一丶集群和Nginx反向代理 ...
- Django+uWSGI+Nginx 部署网站
Django 1.11设置 保证Django在本地调试没有问题: 当然这是前提^_^ 收集静态文件至指定文件夹 Django静态文件设置具体参考:https://docs.djangoproject. ...
- Ubuntu下Django+uWSGI+nginx部署
本文采用uwsgi+nginx来部署django 这种方式是将nginx作为服务端前端,将接受web所有的请求,统一管理,Nginx把所有的静态请求自己处理,然后把所有非静态请求通过uwsgi传递给D ...
- Django+Uwsgi+Nginx部署
一 uwsgi介绍 uWSGI是一个Web服务器,它实现了WSGI协议,uwsgi, http等协议. Nginx中HttpUwsgiMoule的作用是与uWSGI服务器进行交换 1 WSGI是一种W ...
- virtualvenv+django+uWSGI+nginx 部署 踩坑记录
原创博文 转载请注明出处! uwsgi: unrecognized option '--http:8089' uwsgi: unrecognized option '--http' uwsgi trk ...
- django+uwsgi+nginx 部署生产环境
一.Uwsgi安装 python3 -m pip install uwsgi cp /usr/local/python3/bin/uwsgi /usr/bin/ 测试 在django项目主目录下cre ...
- Ubuntu+Django+uWSGI+Nginx部署Django项目
安装uWSGI,pip依据自己要使用的python版本自行选择,python2.x版本使用pip进行安装,python3.x版本使用pip3进行安装 pip install uwsgi 配置uWSGI ...
- Django Uwsgi Nginx 部署
1.django的settings配置 参照博客 https://www.cnblogs.com/xiaonq/p/8932266.html # 1.修改配置 # 正式上线关闭调试模式, 不会暴露服务 ...
随机推荐
- 软件架构设计学习总结(1):标准Web系统的架构分层
1.架构体系分层图 在上图中我们描述了Web系统架构中的组成部分.并且给出了每一层常用的技术组件/服务实现.需要注意以下几点: 系统架构是灵活的,根据需求的不同,不一定每一层的技术都需要使用.例如:一 ...
- 【SpringBoot系列3】SpringBoot使用事务和AOP
前言: 因为SpringBoot操作两者实在太简单了,我就放一起来写了. 正文(事务): /** * springboot中运用事务 * 真的超级方便,直接加上注解就ok了,连配置都省了 * @ret ...
- [转]论magento1和magento2的速度性能优化问题
本文转自:http://www.360magento.com/blog/magento-speed-up/ magento从2007年发展至今,也经历了十余年的磨练,如今也迎来了magento的换代产 ...
- Effective C++ 50条款
条款1:尽量用const和inline而不用#define 以const 行使常量折叠,用inline 代替常用操作的宏定义,而且库里面有很多常用函数可用.当然不能抛弃宏,宏还是很有用滴.偶最近才发现 ...
- 低级问题: jquery-ajax-alert(data) <!DOCTYPE html PUBLIC "-
后台:Response.Write("登录成功"); 前台:Jquery-Ajax--alert(data)弹出: 登录成功 <!DOCTYPE html PUBLIC &q ...
- 安装svn过程
1.SVN服务器端程序安装 --检测是否安装成功:svn --version2.创建版本库(仓库) 命令格式:svnadmin create 仓库的目录 3.启动服务器 <1>命令行方式 ...
- Java JDBC的基础知识(四)
之前学习了如何创建一个数据库工具类,如下: import java.sql.Connection; import java.sql.DriverManager; import java.sql.Res ...
- 【Dubbo&&Zookeeper】1、Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
转自:http://blog.csdn.net/congcong68/article/details/41113239 互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架 ...
- 常见对象(int和String类型的相互转换)
public class Test03 { //基本数据类型包装类有八种,其中其中都有parsexxx的方法 //可以加将这七种字符串表现形式转换成基本数据类型 //char的包装类Character ...
- 使用commons-pool2实现FTP连接池
GitHub : https://github.com/jayknoxqu/ftp-pool 一. 连接池概述 频繁的建立和关闭连接,会极大的降低系统的性能,而连接池会在初始化的时候会创建一定 ...