Technology Sharing

Django project development (Part 2)

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Table of contents

1. Install and use uWSGI

1.1. Installation

1.2 Configuration File

1.3. Start and stop uwsgi

2. Install nginx

3. Nginx configuration uWSGI

4. Nginx configuration static files

5. Nginx load balancing configuration


1. Installation and useuWSGI

image-20211216095808144

uWSGI is a web server that can be used to deploy Python web applications. It is a high-performance general-purpose web server that can run on a variety of operating systems and supports a variety of web service protocols.

Official documentation:The uWSGI project — uWSGI 2.0 documentation

1.1. Installation

pip install uwsgi==2.0.21

1.2 Configuration File

  1. [uwsgi]
  2. # 使用nginx作为web服务器
  3. #socket = 127.0.0.1:8000
  4. # 直接做web服务器
  5. http=192.168.0.182:8000
  6. # 指定项目的根目录
  7. chdir = /opt/django_deploy12
  8. # 指定项目的wsgi文件
  9. wsgi-file = django_deploy12/wsgi.py
  10. # 指定启动的工作进程数
  11. processes = 4
  12. # 指