CentOS7.2 nginx和uwsgi部署django项目步骤:

******[root@kezhongserver ~]# nginx -v
nginx version: nginx/1.10.2

******[root@kezhongserver ~]# uwsgi --version
2.0.15
uwsgi安装步骤:
1.yum install python-devel
2.yum install -y gcc gcc-c++
3.pip install uwsgi

*******[root@kezhongserver conf.d]# pwd
/etc/nginx/conf.d   #kezhongserver.conf存放路径
*******[root@kezhongserver conf.d]# cat kezhongserver.conf
server {
    listen         9011;
    server_name    115.159.3.65
        charset UTF-8;
        access_log      /home/kezhong_access.log;
        error_log       /home/kezhone_error.log;
        client_max_body_size 75M;
        location / {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:9099;
            uwsgi_read_timeout 2;
        }
        location /static {
            expires 30d;
            autoindex on;
            add_header Cache-Control private;
            #root   /home/KeZhongServer;
        root    /;
        }
        location /media {
            root    /home/KeZhongServer;
        }
}
******************启动django项目*************************************
1.启动nginx: [root@kezhongserver ~]# nginx
2.若修改nginx.conf等文件要重载nginx: [root@kezhongserver ~]# nginx -s reload
3.查看nginx状态: ps aux|grep nginx
4.查看部署端口:lsof -i :9011
5.若9011占用: kill -9 12678
6.启动uwsgi:
*****[root@kezhongserver home]# pwd
/home   # uwsgikezhong.ini存放路径
*****[root@kezhongserver home]# (nohup) uwsgi --ini uwsgikezhong.ini
[uwsgi]
vhost = false
plugins = python
socket = 127.0.0.1:9099
master = true
enable-threads = true
workers = 2
wsgi-file = /home/KeZhongServer/KeZhongServer/wsgi.py
chdir = /home/KeZhongServer

你可能感兴趣的:(python,python,django框架,centos7)