centos6 python3 django-uwsgi-nginx 环境搭建04-之组合配置

1.修改myblog_ngnix.conf 文件中的 upstream django{}里面的内容:

#myblog_nginx.conf

# the upstream component nginx needs to connect tou
upstream django {
    server unix:///home/aslan/myblog/myblog.sock; # for a file socket
   #server 127.0.0.1:8080; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name www.maiba360.cn 123.206.254.39; # substitute your machine's IP address or FQDN
    #server_name 10.141.11.215; # 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  {
        #index /home/aslan/myblog/media;  # your Django project's media files - amend as required
        #rewrite /media /usr/share/nginx/html/index.html;  # your Django project's media files - amend as required
        alias /home/aslan/myblog/media; # your Django project's static files - amend as required
    }

    location /static {
        alias /home/aslan/myblog/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     /home/aslan/myblog/uwsgi_params; # the uwsgi_params file you installed
    }
}

 

2.重启ngnix

 

3.在manage.py同一级目录创建myblog_uwsgi.ini

#myblog_uwsgi.ini file
[uwsgi]

# Django-related settings

# process-related settings
# ... with appropriate permissions - may be needed
# chmod-socket    = 664
#stats = 127.0.0.1:9001

# the base directory (full path)
chdir = /home/aslan/myblog/

# the virtualenv (full path)
#home            = /path/to/virtualenv

# Django's wsgi file
wsgi-file = myblog/wsgi.py
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket = /home/aslan/myblog/myblog.sock
# clear environment on exit
vacuum          = true

 

4.执行(3)中的ini脚本

uwsgi --ini myblog_uwsgi.ini

 

5.访问服务器的8000端口,显示django的主页:

103245_q91E_2290420.png

 

6.服务器ps -aux  看后台进程:

103716_Mm14_2290420.png

可以看到ngnix的进程和uwsgi的进程

 

至此,nginx + uwsgi + django + python 的部署就成功了。

 

备注:

python版本 3.5

django版本 1.10

nginx版本:nginx/1.10.2 (命令直接安装的这个版本)

uwsgi版本:2.0.14

 

参考教程:

http://www.jianshu.com/p/e6ff4a28ab5a

 

 

 

 

 

 

转载于:https://my.oschina.net/aslanjia/blog/833846

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值