Project deployment of seed search website based on python

This lecture will explain the deployment process of seed search website in detail.

Website presentation: https://bt.mypython.me

Source address: https://github.com/geeeeeeeek/bt

Project deployment process

System requirement: ubuntu 16.04 (or above)

To build and configure the environment, you must strictly follow the following steps to install and deploy! You can consult if you have any questions (weixin: java2048)

Installation part

Install nginx

sudo apt install nginx

Install python3 and pip3

sudo apt install python3
sudo apt install python3-pip

Installation dependency

pip3 install uwsgi
pip3 install django
pip3 install pymysql
pip3 install django-ratelimit  

Install mysql

sudo apt install mysql-server

Configuration part

Configure mysql(/etc/mysql/my.cnf)

[client]
default-character-set=utf8
[mysqld] 
character-set-server=utf8
[mysql]
default-character-set=utf8

mysql start

/etc/init.d/mysql start

Create database

# Enter database
mysql -u root -p
# Create database
create database bt;
# Sign out
exit();

Pull the code to / var/www /

sudo git clone https://github.com/geeeeeeeek/bt.git

To configure setting.py, you need to configure two things: database and domain name.

Configuration database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'bt',      # Database created
        'USER': 'root',
        'PASSWORD': 'xxx', # Your mysql password
        'HOST':'127.0.0.1',
        'PORT':'3306',
    }
}

Domain name configuration (write your own domain name to allowed hosts)

ALLOWED_HOSTS = ['bt.mypython.me','xxx.com']

Import table structure

python3 manage.py makemigrations
python3 manage.py migrate 

Create superuser

python3 manage.py createsuperuser

Create log file

In the / var/www/bt / directory, create the uwsgi.log file and set the permission to 766

sudo touch uwsgi.log
sudo chmod 766 uwsgi.log

Run configuration (configuration at bt/uwsgi.ini)

uwsgi --ini uwsgi.ini

Configure nginx, create bt.conf under / etc / nginx / sites enabled, write:

upstream bt {
    server 127.0.0.1:8002;
}
 
server {
        listen 80;
        server_name xxx.com; # Your domain name 

        location /static/ {
           alias /var/www/bt/static/;
        } 

        location / {
             include         uwsgi_params;
            uwsgi_pass      bt;
        }

}

Run nginx

sudo service nginx start

be accomplished!

Tags: Web Server MySQL sudo Database Nginx

Posted on Mon, 02 Dec 2019 13:42:01 -0500 by whir