关闭

nginx+uwsgi+django

644人阅读 评论(0) 收藏 举报
分类:

1、安装python

2、安装django

3、安装uwsgi

4、安装nginx

5、uwsgi 配置

在 /etc/uwsgi/apps-enabled下创建文件uwsgi0.xml

内容为:

<uwsgi>
    <socket>127.0.0.1:8001</socket>
    <chdir>/home/pwup/workplace/myproject</chdir>
    <processes>2</processes>
    <module>wsgi</module>
    <plugins>python</plugins>
    <master>true</master>
<enable-threads>true</enable-threads>

<daemonize>/var/log/uwsgi/app/uwsgi_app1.log</daemonize>

<logdate>true</logdate>

</uwsgi>


在 /etc/uwsgi/apps-enabled下创建文件uwsgi2.xml

内容为:

<uwsgi>
    <socket>127.0.0.1:8002</socket>
    <chdir>/home/pwup/workplace/myproject</chdir>
    <processes>2</processes>
    <module>wsgi</module>
    <plugins>python</plugins>
    <master>true</master>

<logdate>true</logdate>

<daemonize>/var/log/uwsgi/app/uwsgi_app2.log</daemonize>

<enable-threads>true</enable-threads>
</uwsgi>


7、/home/pwup/workplace/myproject/wsgi.py 

内容如下:

import os
import sys


sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))


os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


8、启动uwsgi

sudo invoke-rc.d uwsgi start

将自动启动/etc/uwsgi/apps-enabled 下面所有文件配置的uwsgi


9、nginx配置

在/etc/nginx/sites-enabled下面创建文件

test 内容为:

server {
    listen   8000; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6


    server_name test;


    access_log /var/log/nginx/test-access1.log ;
    error_log /var/log/nginx/test-error1.log ;


    location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:8001;
    }


}


创建test2

内容为:

server {
    listen   8009; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6


    server_name test2;


    access_log /var/log/nginx/test-access2.log ;
    error_log /var/log/nginx/test-error2.log ;


    location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:8002;
    }


}

10、启动nginx

sudo nginx 

11、停止nginx

sudo nginx -s stop

12、重新加载nginx

sudo nginx -s reload

注意:

a、uwsgi安装的时候,要装

uwsgi-plugin-python
python-dev

ngix 
libpcre3 libpcre3-dbg libpcre3-dev



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:88812次
    • 积分:1814
    • 等级:
    • 排名:千里之外
    • 原创:83篇
    • 转载:47篇
    • 译文:0篇
    • 评论:3条
    文章分类
    最新评论