Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of deploying Django Project in Pagoda under CentOS

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the method of deploying the Django project under the pagoda under CentOS, the content is clear, interested friends can learn, I believe it will be helpful after reading it.

Basic environment

Install the pagoda, install the service pagoda, install [Python project manager] pagoda, install [Nginx]

Send the Django project code to the server

There are two ways to put code on the server:

Method one: install Git on the server and send the Git Clone code to the server. Method two: upload the code to the server through the pagoda's FTP tool.

Note: create a new folder under the directory: / www/wwwroot/, and put the code in the new directory

Create a Python (Django) project

Now let's start creating the python project. Open the python Project Manager on the home page and click add Project. Populate the data:

* Project name: custom is fine.

* path: navigate to the path where the manage.py file is located

* Python version: select the python version corresponding to your project

* frame: select Django

* Startup method: uswgi

* Startup file / file plus: navigate to the path where wsgi.py is located

* Port: just customize it, after setting the port number of 1024

* check whether to install module dependency and boot

Click OK and wait for creation.

Set up the website service and configure the static file agent

The above operation has been started internally, and the next step is to set up the website service, provide external access, and set up the nginx agent to load static files.

Click "Mapping" in the python project manager to set the domain name (or public network IP).

After the mapping is successful, view it in the [website] menu in the panel sidebar. (it is now accessible externally. But there are no static files)

Click on the domain name or ip we have just mapped in the website, and a pop-up window will appear. Select reverse proxy-"profile."

Find a gap to add static files and media resource configuration.

About static files: the location where the css,js files are stored. Named after static in the django framework. Https://my.openwrite.cn/logout

About media resources: for example, the location where users upload pictures, which is generally named media. Write whatever name you set.

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

According to the file path setting, only need to replace the red box, change to your path, the rest do not need to move.

Next, go back to the front page, click python Project Manager, and select the project to restart.

Click Nginx to reload the configuration after the restart is completed.

At this point, everything is all right! You can access it through the domain name or ip you set up.

After reading the above content, do you have a better understanding of the method of deploying the Django project in the pagoda under CentOS? if you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report