腾讯云ubuntu16.04下部署django项目
Posted Python_Boy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了腾讯云ubuntu16.04下部署django项目相关的知识,希望对你有一定的参考价值。
服务器:腾讯云 s2 标准版
系统版本:ubuntu 16.04
django版本:1.10
项目的部署步骤:
一:安装uwsgi
1.安装uwsgi之前首先要配置c-python解释器:sudo apt-get install build-essential python-dev
2.安装uwsgi:sudo pip install uwsgi
3.测试是否安装成功uwsgi --http :8000 --wsgi-file test.py
可以看到安装成功,先把uwsgi结束
二:
1.在我的django项目根目录下创建jjmovie_uwsgi.ini配置文件 以及 uwsgi_params 文本文件
在配置文件中添加:
1 # wxmovie_uwsgi.ini file 2 [uwsgi] 3 4 # Django-related settings 5 6 socket = :8004 7 8 # the base directory (full path) 9 chdir = /home/ubuntu/jjmovie 10 11 # Django s wsgi file 12 module = jjmovie.wsgi 13 14 # process-related settings 15 # master 16 master = true 17 18 # maximum number of worker processes 19 processes = 1 20 threads = 1 21 22 # ... with appropriate permissions - may be needed 23 # chmod-socket = 664 24 # clear environment on exit 25 vacuum = true 26 python-autoreload = 1
在文本文件中插入:
1 uwsgi_param QUERY_STRING $query_string; 2 uwsgi_param REQUEST_METHOD $request_method; 3 uwsgi_param CONTENT_TYPE $content_type; 4 uwsgi_param CONTENT_LENGTH $content_length; 5 6 uwsgi_param REQUEST_URI $request_uri; 7 uwsgi_param PATH_INFO $document_uri; 8 uwsgi_param DOCUMENT_ROOT $document_root; 9 uwsgi_param SERVER_PROTOCOL $server_protocol; 10 uwsgi_param REQUEST_SCHEME $scheme; 11 uwsgi_param HTTPS $https if_not_empty; 12 13 uwsgi_param REMOTE_ADDR $remote_addr; 14 uwsgi_param REMOTE_PORT $remote_port; 15 uwsgi_param SERVER_PORT $server_port; 16 uwsgi_param SERVER_NAME $server_name;
以上是关于腾讯云ubuntu16.04下部署django项目的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu 16.04部署python项目(Nginx+uwsgi+django)
6.django restframework 项目部署到ubuntu18.04上(配置域名与https)