Detailed tutorial on deploying Django project under CentOS

Detailed tutorial on deploying Django project under CentOS

Basic Environment

  • Pagoda installation service
  • [Python Project Manager] installed in the pagoda
  • Installed in the pagoda [Nginx]

Send the Django project code to the server

There are two ways to put the code on the server:

  • Method 1: Install Git on the server and clone the code to the server via Git
  • Method 2: Upload the code via Baota's FTP tool

Note: Create a new folder in the directory: /www/wwwroot/ and put the code into the new directory

Creating a Python (Django) Project

Now we start creating a python project. Open the Python Project Manager on the homepage and click Add Project. Fill data:
* Project name: Customizable
* Path: Locate the path where the manage.py file is located
* Python version: Select the Python version corresponding to your project
* Framework: Choose Django
* Startup method: uswgi
* Startup file/file plus: locate the path where wsgi.py is located
* Port: You can customize it, set the port number after 1024
* Check whether to install module dependencies and start at boot, click OK, and then wait for creation.

Set up website service and configure static file proxy

We have already started the above operations internally. The next step is to set it up as a website service, provide external access, and set up nginx proxy to load static files.

In the Python Project Manager, click [Mapping] and set the domain name (or external IP).

After the mapping is successful, check it in the [Website] menu on the panel sidebar. (It can be accessed externally at this point. But there are no static files)

Click on the domain name or IP we just mapped on the website, a pop-up window will appear, select Reverse Proxy -> Configuration File

Find a gap to add configuration for static files and media resources.

About static files: It is the location where css and js files are stored. Named static in the Django framework. https://my.openwrite.cn/logout

About media resources: For example, the storage location of pictures uploaded by users is generally named media. Just write whatever name you set.

location /static/ {
alias /www/wwwroot/myblog/static/;
}
location /media/ {
alias /www/wwwroot/myblog/media/;
}

Just follow the file path settings. You only need to replace the red box with your path, and leave the rest unchanged.

Next, go back to the home page of the panel, click Python Project Manager, and select the project to restart.

After the restart is complete, click Nginx to reload the configuration.

At this point, everything is fine! You can access it through the domain name or IP you set.

This is the end of this article about the detailed tutorial on how to deploy Django projects on CentOS. For more information about how to deploy Django projects on CentOS, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of the deployment of Django to CentOS7
  • Deploy the Django project to the CentOs server
  • Detailed explanation of the whole process of centos7+django+python3+mysql+Alibaba Cloud deployment project
  • Tutorial on deploying nginx+uwsgi in Django project under Centos8
  • How to deploy Django service nginx+uwsgi on Centos
  • Detailed tutorial on deploying Django project using Docker on centos8
  • How to deploy Django project to CentOS

<<:  js implements shopping cart addition and subtraction and price calculation

>>:  MySql Installer 8.0.18 Visual Installation Tutorial with Pictures and Text

Recommend

Design Story: The Security Guard Who Can't Remember License Plates

<br />In order to manage the vehicles enteri...

How to configure Nginx load balancing

Table of contents Nginx load balancing configurat...

Draw an iPhone based on CSS3

Result:Implementation Code html <div class=...

JavaScript canvas to achieve colorful clock effect

Use canvas to write a colorful clock! 1. Title (1...

Teach you how to use webpack to package and compile TypeScript code

TypeScript Bundling webpack integration Usually, ...

MySQL index for beginners

Preface Since the most important data structure i...

Graphic tutorial on installing Mac system in virtual machine under win10

1. Download the virtual machine version 15.5.1 I ...

Nginx anti-crawler strategy to prevent UA from crawling websites

Added anti-crawler policy file: vim /usr/www/serv...

Vue uses the method in the reference library with source code

The official source code of monaco-editor-vue is ...

Web designer is a suitable talent

<br />There is no road in the world. When mo...

MySQL Series 8 MySQL Server Variables

Tutorial Series MySQL series: Basic concepts of M...

Vue implements calling PC camera to take photos in real time

Vue calls the PC camera to take pictures in real ...

MySQL series 6 users and authorization

Table of contents Tutorial Series 1. User Managem...

JavaScript implements an input box component

This article example shares the specific code for...