The cloud server uses Baota to build a Python environment and run the Django program

The cloud server uses Baota to build a Python environment and run the Django program

Before you get started, you need a server.

Install Pagoda

Baota official website: https://www.bt.cn/

If you are using CentOS system, use the following command to install it.

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

After the installation is complete, the access address, account number and password will appear.

The first thing to do at this time is to go to the control panel of the cloud server and open port 8888 You can search the security group configuration for details and open the port.

Visit the address after the Baota installation again, and you can see the login interface, which means the port is open and the Baota can operate normally.

Configure Python runtime environment

Open the software store of Baota and install the relevant content as shown in the figure below. After logging in to Baota by default, it will recommend installing LAMP or LNMP . Just select the recommended installation.

Please note that the Python Project Manager mentioned above is an essential plug-in for our subsequent operations on Python programs.

Install Python

Click the Settings button on the right side of the Python Project Manager, select Version Management in the pop-up window, and then install the Python version you need. The installation speed here is a bit slow, so just wait for a while.

Configure Django environment

When configuring the Django environment, be sure to refer to the following figure for configuration. Whether to install module dependencies depends on whether there is a requirements.txt file in your project. If so, you can check it. The module can also be configured separately after the project is started.

Installing the Module

After the project is initialized, click the module on the right to manually install the modules used in the project, such as django .

When installing a module, be sure to pay attention to the version number. For example, I use version 2.x of Django locally, so the server also installs this version.

After all modules are installed, you can restart the Python service. Here you need to pay attention to the log content to make sure that the restart is successful.

Various problems that occur during the operation of Python Django will be shown here.

For example, during the first run, the sqlite3 version of the Centos system may be too low, and the words SQLite 3.xx or later will appear in the log. At this time, you need to upgrade the SQlite version.

The following content is reproduced from the Internet (https://www.jb51.net/article/231391.htm, thanks to the original author, you can refer to it for upgrade)

# Update for SQLite 3
# Get the source code (run in your home directory)
[root@djangoServer ~]# cd ~
[root@djangoServer ~]# wget https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz
[root@djangoServer ~]# tar -zxvf sqlite-autoconf-3270200.tar.gz

#Build and install [root@djangoServer ~]# cd sqlite-autoconf-3270200
[root@djangoServer sqlite-autoconf-3270200]# ./configure --prefix=/usr/local/sqlite
[root@djangoServer sqlite-autoconf-3270200]# make && make install

# Check version ## The latest installed sqlite3 version [root@djangoServer ~]# /usr/local/sqlite/bin/sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@djangoServer ~]#

## Centos7's own sqlite3 version [root@djangoServer ~]# /usr/bin/sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@djangoServer ~]#

## You can see that the version of sqlite3 is still an old version, so it needs to be updated.
[root@djangoServer ~]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@djangoServer ~]#

## Changes to old sqlite3
[root@djangoServer ~]# mv /usr/bin/sqlite3 /usr/bin/sqlite3_old

## Soft link sets the new sqlite3 to the /usr/bin directory [root@djangoServer ~]# ln -s /usr/local/sqlite/bin/sqlite3 /usr/bin/sqlite3

## View the current global sqlite3 version [root@djangoServer ~]# sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@djangoServer ~]#

# Pass the path to the shared library # Set the boot-up execution to be executed automatically. You can write the following export statement to the ~/.bashrc file. If you want it to take effect immediately, you can execute source ~/.bashrc. It will be executed every time you start the terminal. [root@djangoServer ~]# export LD_LIBRARY_PATH=/usr/local/sqlite/lib

As long as it is running and no error data is generated in the log, it means the configuration is successful. Next, you can set up the nginx reverse proxy.

nginx reverse proxy

Click the mapping button in the picture below and enter the domain name or server external IP.

Return to the Baota website function menu and you will see a new site appear.

Click on the website name to view its reverse proxy configuration and make sure it is running.

At this point, you can open a browser and enter the domain name or IP to test whether you can access the Django program normally. If an error still occurs, check the settings.py file in the project root directory to see if the following content, namely ALLOWED_HOST , is configured.

If your Django program still has static resources, be sure to go to the reverse proxy configuration (find a blank line) and add the static directory configuration.

    location /static/
    {
        alias /www/wwwroot/project address/static/;
    }

Finally, remember to confirm whether the website port is accessible in the pagoda, such as 8000 in this case.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Deploy WeChat applet backend service based on Tencent Cloud Server (Python+Django)
  • Django production environment construction (uWSGI+django+nginx+python+MySQL)
  • Teach you to build Django framework with Python3+mysql8.0

<<:  Vue+ElementUI implements paging function-mysql data

>>:  Count the list tags in HTML

Recommend

Analysis of the Docker deployment Consul configuration process

Execute Command docker run -d --name consul -p 85...

How to regularly clean up docker private server images

Using CI to build docker images for release has g...

How to install MySQL 5.7 on Ubuntu and configure the data storage path

1. Install MySQL This article is installed via AP...

How to add fields and comments to a table in sql

1. Add fields: alter table table name ADD field n...

Implementation of scheduled backup in Mysql5.7

1. Find mysqldump.exe in the MySQL installation p...

How to use CocosCreator object pool

Table of contents Preface: Specific operations St...

6 Uncommon HTML Tags

First: <abbr> or <acronym> These two s...

Solve the problem of blank gap at the bottom of Img picture

When working on a recent project, I found that th...

Do designers need to learn to code?

Often, after a web design is completed, the desig...

Vue dynamic menu, dynamic route loading and refresh pitfalls

Table of contents need: Ideas: lesson: Share the ...

JavaScript canvas realizes the effect of nine-square grid cutting

This article shares the specific code of canvas t...

MySQL lock control concurrency method

Table of contents Preface 1. Optimistic Locking A...

Pure CSS to achieve the effect of picture blinds display example

First, let me show you the finished effect Main i...

CSS3 realizes the website product display effect diagram

This article introduces the effect of website pro...

What is JavaScript anti-shake and throttling

Table of contents 1. Function debounce 1. What is...