系统相关
首页 > 系统相关> > uwsgi + nginx + django部署服务器

uwsgi + nginx + django部署服务器

作者:互联网

1. uwsgi 安装

pip install uwsgi

2. nginx 安装

sudo apt-get install nginx

3. 新建blogs_uwsgi.ini文件

[uwsgi]

socket = 127.0.0.1:9000

chdir = /home/alex/PycharmProjects/blogsProject 

wsgi-file = blogsProject/wsgi.py

processes = 4

threads = 2

stats = 127.0.0.1:9191

vacuum = true

disable-logging = true

4. /etc/nginx/conf.d 下新建 blogs.conf 文件

upstream django {
    server 127.0.0.1:9000;
}

server {
    listen      8080;
    server_name localhost; 
    charset     utf-8;

    client_max_body_size 75M; 

    location /static {
        alias /home/alex/PycharmProjects/blogsProject/static;     
    }

    location / {
        uwsgi_pass  django;
        include     uwsgi_params; 
    }

}

5. django配置STATIC_ROOT(settings.py中)

STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

6. 收集static

python manage.py collectstatic

7. 启动nginx 

sudo service nginx start

8. 启动uwsgi

uwsgi blogs_uwsgi.ini中

结束

 

标签:0.1,server,nginx,static,django,uwsgi
来源: https://www.cnblogs.com/SixEight/p/16298136.html