安装python3.6 yum -y install xz wget gcc make gdbm-devel openssl-devel sqlite-devel zlib-devel bzip2-devel wget http://mirrors.sohu.com/python/3.6.3/Python-3.6.3.tar.xz tar -xf Python-3.6.3.tar.xz cd Python-3.6.3 ./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib ./configure --enable-optimizations make && make install mv /usr/bin/python /usr/bin/python2.7 ln -s /usr/local/bin/python3 /usr/bin/python vim /etc/ld.so.conf /usr/local/lib include ld.so.conf.d/*.conf /sbin/ldconfig python –V vim /usr/bin/yum #!/usr/bin/python2.7 修改源 /root/.pip/pip.conf [global] trusted-host=mirrors.aliyun.com index-url= pip3 install uwsgi django
命令启动: uwsgi --http :8001 --chdir /opt/autoops/ -w autoops.wsgi --static-map=/static=static vim uwsgi.ini [uwsgi] # 项目目录 chdir=/opt/autoops/ # 指定项目的application module=autoops.wsgi:application # 进程个数 workers=8 pidfile=/opt/autoops/script/uwsgi.pid # 指定IP端口 #http=0.0.0.0:8003 ##可以不启用,利用socket文件,如果只是测试,需要启用 # 指定静态文件 static-map=/static=/opt/autoops/static # 启动uwsgi的用户名和用户组 uid=root gid=root # 启用主进程 master=true # 自动移除unix Socket和pid文件当服务停止的时候 vacuum=true # 序列化接受的内容,如果可能的话 thunder-lock=true # 启用线程 enable-threads=true # 设置自中断时间 harakiri=30 # 设置缓冲 post-buffering=4096 # 设置日志目录 daemonize=/opt/autoops/script/uwsgi.log # 指定sock的文件路径 socket=/opt/autoops/script/uwsgi.sock
uwsgi --ini uwsgi.ini # 启动uwsgi配置 uwsgi --stop script/uwsgi.pid # 关闭uwsgi uwsgi --reload script/uwsgi.pid #重新加载
安装nginx,可参看 修改 nginx.conf root /opt/autoops; location / { # uwsgi_pass 127.0.0.1:8003; include uwsgi_params; uwsgi_connect_timeout 30; uwsgi_pass unix:/opt/autoops/script/uwsgi.sock; } location /static/ { alias /opt/autoops/static/; index index.html index.htm; } 启动测试
附:安装mysql 可以参考 http://hequan.blog.51cto.com/5701886/1982428
本文出自 “何全” 博客,请务必保留此出处http://hequan.blog.51cto.com/5701886/1982769
django1.11.6+nginx1.12.2+uwsgi2.0.15 部署 | autoops 生产环境部署指南
原文地址:http://hequan.blog.51cto.com/5701886/1982769