国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Ubuntu 14.04+Django 1.7.1+Nginx+uwsgi部署教程

2020-02-23 06:11:31
字體:
來源:轉載
供稿:網(wǎng)友

具體環(huán)境:
Ubuntu 14.04 Python 2.7.6 Django 1.7.1 Virtualenv name:test Nginx uwsgi

假設 項目文件夾位于 /data/www/ts 設置保存在 ./conf

代碼如下:
virtualenv name = test
domain name = example.com

django+uwsgi的部署實在是太蛋疼了..網(wǎng)上已有的教程似乎有新版本的兼容問題。最后跑到uwsgi官網(wǎng)上找的教程終于跑通了..
不過官網(wǎng)的教程似乎有引導教學性質,部署的時候就顯得很繞彎路,在這里記錄下來精簡內容

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

首先,需要一個uwsgi_params文件,放在項目的conf文件夾里面。之后需要指向它。文件內容如下:

代碼如下:
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

創(chuàng)建一個叫做ts_nginx.conf 的文件,內容如下

代碼如下:
# ts_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen 80;
    # the domain name it will serve for
    server_name .example.com; # substitute your machine's IP address or FQDN
    charset utf-8;

    # max upload size
    client_max_body_size 75M; # adjust to taste

    # Django media
    location /media {
        alias /data/www/ts/media; # your Django project's media files - amend as required
    }

    location /static {
        alias /data/www/ts/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass django;
        include /data/www/ts/conf/uwsgi_params; # the uwsgi_params file you installed
    }
}

把這個conf文件連接到nginx的搜索目錄里面。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 彭阳县| 扬中市| 江北区| 永州市| 嫩江县| 安庆市| 吴川市| 黄平县| 清丰县| 伊宁县| 海阳市| 隆子县| 长岭县| 峨边| 南漳县| 佛学| 马边| 陇川县| 改则县| 孝昌县| 温州市| 昭通市| 台前县| 杂多县| 丹江口市| 平湖市| 张家界市| 长沙县| 洛川县| 香港 | 册亨县| 临潭县| 孝义市| 安宁市| 叶城县| 云林县| 开远市| 云和县| 家居| 怀集县| 正定县|