第一步 创建项目启动脚本

# 创建项目启动脚本 vi /etc/init.d/project_name
#!/bin/bash
# Description: uwsgi manager scripts
# chkconfig: -
#
# Get function from functions library
. /etc/init.d/functions pidfile='/var/www/run/project_name.pid'
conf='/var/www/config/project_name.ini' startcmd="/usr/bin/uwsgi --pidfile $pidfile -i $conf"
stopcmd="/usr/bin/uwsgi --stop $pidfile"
reloadcmd="/usr/sbin/uwsgi --reload $pidfile"
start() {
if ps -ef |grep -v grep |grep -q $pidfile;then
echo -n "uwsgi aleardy running ... "
echo
else
echo -n "Starting uwsgi: "
$startcmd &> /dev/null
if [ $? -eq ];then
### Create the lock file ###
success $"uwsgi startup"
echo
else
failure $"uwsgi startup"
echo && exit
fi
fi
}
stop() {
echo -n "Stopping uwsgi: "
### Stop
$stopcmd
if [ $? -eq ];then
### Now, delete the lock file ###
success $"uwsgi shutdown"
echo
else
rm -f $lockfile
failure $"uwsgi shutdown"
echo && exit
fi
} reload() {
echo -n "Reloading uwsgi: "
$reloadcmd
if [ $? -eq ];then
success $"uwsgi reload"
echo
else
failure $"uwsgi reload"
echo && exit
fi
} status() {
if ps -ef |grep -v grep |grep -q $pidfile;then
pidnum=$(cat $pidfile)
echo "uwsgi (pid $pidnum) is running..."
else
echo "uwsgi is stoped."
exit
fi
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
sleep
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|status}"
exit
esac
exit

第二步 配置uwsgi

$ pip install uwsgi   # 如未安装则先安装uwsgi

# vi /var/www/config/pad_math2_api.ini
[uwsgi]
;http-socket = :
socket = 127.0.0.1:
chdir = /var/www/pad_math2_api/esms/
pythonpath = /var/www/pad_math2_api/
env = DJANGO_SETTINGS_MODULE=esms.custom_settings
#module = django.core.handlers.wsgi:WSGIHandler()
module = django.core.wsgi:get_wsgi_application()
workers =
max-request =
listen =
harakiri =
enable-threads = true
master = true
daemonize = /var/www/logs/pad_math2_api.uwsgi.log

第三步 配置nginx

# server {}
# include /usr/local/nginx/conf/pythonapp/*; server {
listen ;
#server_name 192.168.0.76;
#access_log logs/pad_math2_api.log main;
#error_log logs/pad_math2_api_error.log; location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:;
}
}
server {
listen ;
server_name domain.cn www.domain.cn 101.201.48.0;
access_log /data/logs/www.domain.cn_access.log;
error_log /data/logs/www.domain.cn_error.log; server_name_in_redirect off;
if ($host != www.domain.cn) {
rewrite ^(.*)$ http://www.domain.cn$1 permanent;
} location ^~/site_media/ {
alias /data/www/yj_web/cms/site_media/;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov) {
access_log off; # po co mi logi obrazk¨®w :)
expires 30d;
} location ^~/ {
root /data/www/yj_web/cms/templates/html;
index index.html index.htm;
} }

.

django + ngxin + uwsgi 站点部署的更多相关文章

  1. 「Linux+Django」Django+CentOs7+uwsgi+nginx部署网站记录

    转自:http://www.usday.cn/blog/51 部署前的准备: 1. 在本地可以运行的django项目 2. 一台云服务器,这里选用Centos系统 开始部署: 首先在本地导出项目需要的 ...

  2. django+nginx+uwsgi 项目部署

    Django虽然自带一个Server,但只能作为开发时测试使用,我们需要一个可以稳定而持续的服务器对网站进行部署,比如Apache, Nginx, lighttpd等,本篇将利用nginx和uWSGI ...

  3. virtualvenv+django+uWSGI+nginx 部署

    原创博文 转载请注明出处! 1. virtualvenv 2. django 3. uWSGI 4. nginx 5. 踩坑记录 1. virtualvenv virtualvenv install ...

  4. 使用uWSGI+nginx部署Django项目

    最近使用django写了一些项目,不过部署到服务器上碰到一些问题,还有静态文件什么的一堆问题,这里总结一下碰到的问题和解决方案,总体思路是按照官方文档走的. 原文地址:http://uwsgi-doc ...

  5. CentOS上部署Django+Nginx+Uwsgi环境

    在CentOS上部署Django+Nginx+Uwsgi环境 奇谭  2016-09-01 评论  Linux  python django nginx uwsgi VirtualEnv的作用:创建隔 ...

  6. django+uwsgi+nginx部署(非常详细)

    django+uwsgi+nginx部署 1.介绍: 在网上看了很多教程,但自己部署了很久都没有成功,这篇博文记录自己所踩过得坑. 2.环境: Ubuntu 16.04.1 LTS (GNU/Linu ...

  7. ubuntu18+uwsgi+nginx部署django项目

    更新系统软件源 sudo apt-get update pip3安装 sudo apt install python3-pip 安装virtualenvwrapper pip3 install vir ...

  8. Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx)

    Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx) 一丶集群和Nginx反向代理 ...

  9. Django+uWSGI+Nginx 部署网站

    Django 1.11设置 保证Django在本地调试没有问题: 当然这是前提^_^ 收集静态文件至指定文件夹 Django静态文件设置具体参考:https://docs.djangoproject. ...

随机推荐

  1. 计算字符串相似度算法——Levenshtein

    转自:http://wdhdmx.iteye.com/blog/1343856 0.这个算法实现起来很简单 1.百度百科介绍: Levenshtein 距离,又称编辑距离,指的是两个字符串之间,由一个 ...

  2. 【HTML5】地理定位

    <!DOCTYPE html> <html> <body> <p id="demo">点击这个按钮,获得您的坐标:</p> ...

  3. Scala中的Implicit(隐式转换,隐式参数,隐式类)

    文章来自:http://www.cnblogs.com/hark0623/p/4196452.html  转发请注明 代码如下: /** * 隐式转换 隐式参数 隐式类 */ //隐式转换 class ...

  4. mysql查询表里的重复数据方法:

    INSERT INTO hk_test(username, passwd) VALUES ('qmf1', 'qmf1'),('qmf2', 'qmf11') delete from hk_test  ...

  5. HeapByteBuffer和DirectByteBuffer以及回收DirectByteBuffer

    由于HeapByteBuffer和DirectByteBuffer类都是default类型的,所以你无法字节访问到,你只能通过ByteBuffer间接访问到它,因为JVM不想让你访问到它. 分配Hea ...

  6. html简单框架网页制作

    先把框架分结构 top顶端 <img src="title.jpg"/> left左侧 <body bgcolor="pink"> &l ...

  7. HDU 4632 Palindrome subsequence(DP)

    题目链接 做的我很无奈,当时思路很乱,慌乱之中,起了一个想法,可以做,但是需要优化.尼玛,思路跑偏了,自己挖个坑,封榜之后,才从坑里出来,过的队那么多,开始的时候过的那么快,应该就不是用这种扯淡方法做 ...

  8. BZOJ3236: [Ahoi2013]作业

    Description Input Output Sample Input 3 4 1 2 2 1 2 1 3 1 2 1 1 1 3 1 3 2 3 2 3 Sample Output 2 2 1 ...

  9. 一个简单的SqlServer游标使用

    declare @id int ) declare c_department cursor for select id,name from department open c_department f ...

  10. [shell] if else以及大于、小于、等于逻辑表达式 [转]

    本文也即<Learning the bash Shell>3rd Edition的第五章Flow Control之读书笔记,但我们将不限于此.flow control是任何编程语言中很常用 ...