Python common project deployment process

Time:2021-6-9

Project deployment process

Update system source

sudo apt-get update

The reason for updating the system source is that many of the software installed in the virtual machine we purchased has not been updated to the latest version, and there may be problems in subsequent installation

Install dependency package

#Install the dependency Library of GCC G + +

The purpose of updating the dependency library is to prevent errors during the subsequent installation of nginx

Setup Toolkit

#Install Git

You can upload our project to the cloud server through git or RZ. Students using pychar can update the project synchronously with the deployment tool in tools

Install python3 and PIP3

sudo apt install python3
sudo apt install python3-pip

Now most of the projects are based on python3, using the system’s own Python may have problems, the general Ubuntu system comes with python3, 16.04 comes with python3.5, 18.04 comes with python3.6, students who want other versions can install their own version, PIP version is recommended to update to the latest, the current version is 19

Install virtual environment management virtualenv

sudo pip3 install virtualenv

Virtual environment is a relatively independent environment. You can create different virtual environments for different projects. In Python, you can manage the virtual environment by installing virtualenv. Here, you must use PIP3 to install

Establishing project folder and virtual environment folder

#Project folder

Create and start the virtual environment and test it

#View the path of Python 3

Upload project and test project

#Upload projects through git or RZ

Possible problems:

1. There is no CSS in the admin interface

Solution:

Set debug to true

Install uwsgi

1. Install uwsgi in virtual environment

in:sudo pip install uwsgi

2

1. Set static in the settings file_ Root directory

STATIC_URL = ‘/static/‘

STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)

2. Execute the collectstatic command under the project entry

python manage.py collectstatic

Executing this command will download all CSS and JS of the project to the static directory under the root directory of the project

This work adoptsCC agreementReprint must indicate the author and the link of this article