centos7+nginx+gunicorn+django阿里云部署

updated at 2018-04-02

参照:www.digitalocean.com/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7

sudo vim /etc/systemd/system/gunicorn.service[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=ouyi
Group=ouyi
WorkingDirectory=/home/ouyi/creditmg
EnvironmentFile=/home/ouyi/creditmg/.env
ExecStart=/home/ouyi/.local/share/virtualenvs/creditmg-F6Yq17ql/bin/gunicorn \
          --worker-class=gevent --workers 3 \
          --bind unix:/home/ouyi/creditmg/gunicorn.sock creditmg.wsgi:application

[Install]
WantedBy=multi-user.target
sudo systemctl start gunicorn
sudo systemctl enable gunicorn


sudo vim /etc/nginx/nginx.conf
    server {
      charset utf-8;
      listen 80;
      listen [::]:80;
      server_name gullwing.cn 120.78.198.93;

      location = /favicon.ico { access_log off; log_not_found off; }

      location /static {
        alias /home/ouyi/creditmg/collectstatic;
      }

      location /media {
        alias /home/ouyi/creditmg/media;
      }

      location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://unix:/home/ouyi/creditmg/gunicorn.sock;
        # proxy_read_timeout 300;
      }
    }
sudo usermod -a -G `whoami` nginx
chmod 710 /home/`whoami`
sudo nginx -t
sudo systemctl start nginx
sudo systemctl enable nginx

PS: 查看与用户同名的组有哪些成员:

cat /etc/group|grep `whoami`
adm:x:4:syslog,ubuntu
dialout:x:20:ubuntu
cdrom:x:24:ubuntu
floppy:x:25:ubuntu
sudo:x:27:ubuntu
audio:x:29:ubuntu
dip:x:30:ubuntu
video:x:44:ubuntu
plugdev:x:46:ubuntu
netdev:x:109:ubuntu
lxd:x:110:ubuntu
ubuntu:x:1000:
#组名称  组密码   组ID(GID)  组成员
新建与用户同名的组:
groupadd `whoami`



------------------------------------------

2017-10-31

关键步骤:

nginx.conf中设置

proxy_pass http://172.18.204.154:9000;    # 172.18.204.154为阿里云私网IP

终端启动

nohup gunicorn --worker-class=gevent romanloaddotcom.wsgi:application -b 172.18.204.154:9000&


其它基本参照:http://www.isaced.com/post-248.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值