django1.11.6+nginx1.12.2+uwsgi2.0.15 部署 | autoops 生產環境部署指南
阿新 • • 發佈:2017-11-17
nginx uwsgi djang autoops
安裝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 生產環境部署指南