Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to configure the django environment

Shulou Source: shulou.com Published: 2022-06-01 07:53:19 09月26日 Update

This article focuses on "how to configure the django environment", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure the django environment.

Environment description:

Ali Cloud ECS, Ubuntu, Nginx, Python3, Django, Supervisord

1. Update ubuntu to avoid later installation errors

Sudo apt updatesudo apt upgrade

Install and configure nginx

Apt-get install nginx

Create a project directory with a permission of 755

Mkdir / opt/web/venv/mysitechmod 755 web

Create VHost configuration create server configuration files such as myserver.conf under / etc/nginx/sites-available/

Note: the configuration file is suffixed with .conf

Create a soft connection

Ln-n / etc/nginx/sites-available/myserver.conf / etc/nginx/sites-enabled/myserver.conf

Add site information to the configuration file

Django

Server {listen 80; server_name www.mmfinding.cn mmfinding.cn; charset utf-8; client_max_body_size 75M; location / static {alias / opt/web/venv/mysite/collected_static;} location / {proxy_pass http://127.0.0.1:9001; proxy_set_header Host $host Proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}

3. Install python3-dev

Apt-get install python3-dev

4. Virtual environment

Install python3-venv

Apt-get install python3-venv

Generate a virtual environment in the specified current directory ('/ opt/web/venv')

Python3-m venv.

Enter the virtual environment

Source bin/activate

Exit the virtual environment

Deactivate

5. Use supervisor to manage processes

Installation

Apt-get install supervisor

Start the service

Supervisord-c / etc/supervisor/supervisord.conf

Check to see if supervisord is running

Ps aux | grep supervisord

Add process management (/ etc/supervisor/conf.d/mysite.conf)

[program:mysite] command=/opt/web/vevn/bin/gunicorn-- worker-class=gevent mysite.wsgi:application-b 127.0.0.1:9001directory=/opt/web/venv/mysiteuser=root here, I believe you have a deeper understanding of "how to configure the django environment". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Environment configuration files directories content processes learning services management practicality deeper information interests suffixes practicality practicality simplicity of operation methods more friends Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker Huawei MariaDB Shulou Technology