第一步 创建项目启动脚本

# 创建项目启动脚本 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;
} }

.

最新文章

  1. setprecision、fixed、showpoint的用法总结
  2. iOS JsonModel 的使用
  3. Atitit图片复制父目录给你设计的实现 基于win 图片浏览器
  4. iphone删除自动更新的系统
  5. 转:Web页面通过URL地址传递参数常见问题及检测方法
  6. Android 自定义Toast
  7. armp启动
  8. iOS 非ARC基本内存管理系列 1-引用计数器
  9. 九度OJ1184二叉树
  10. 自己定义标签中tagsupport的一些方法
  11. 关于frameset的一些小总结
  12. 一步步带你做vue后台管理框架(一)——介绍框架
  13. 常见web攻击总结
  14. Postman安装与使用
  15. SSM单元测试时出现:Failed to load ApplicationContext的一种可能解决办法
  16. HDU - 1540 线段树的合并
  17. git(转载谢谢)
  18. [命令]在uboot下查看文件系统的目录结构
  19. HDU 2602 - Bone Collector - [01背包模板题]
  20. 去除Layer自带隐藏动画

热门文章

  1. 关于WM_CTLCOLOREDIT的处理的一些问题
  2. js 事件监听 冒泡事件
  3. php session跨页面传递 session值丢失问题
  4. 【word xml】将word转化为xml格式后,如何在xml中卫word添加分页符
  5. Python实践:开篇
  6. HTML-Canvas02
  7. js:数据结构笔记1---数组
  8. 简单几何(线段相交) POJ 2826 An Easy Problem?!
  9. System call in linux by C
  10. HDU 3853(期望DP)