Deploy front-end and back-end separation projects based on physical machines

Software Installation 

install git

install mysql

install redis

install python

Install the virtual environment

install uwsgi

install nginx

CentOS installs common software_Riding Typhoon Walking Blog-CSDN Blog Uninstall mysql### 1 View the installation of mysql rpm -qa |grep -i mysql # -i means ignore case''' mysql80-community-release-el7 -7.noarch mysql-community-common-8.0.32-1.el7.x86_64 mysql-community-clie...Centos7 installs Mysql5.7--Mysql8 four schemes- Zhihu. https://blog.csdn.net/qq_52385631/article/details/131576514?spm=1001.2014.3001.5501

step

The request URL sent by the front end, the request sent to 8000 is captured and forwarded by nginx

http://10.0.0.100:8000/api/v1/banner/s

deployment steps

# 本地收集static dist 上传
python manage.py collectstatic
# 拉项目
https://gitee.com/yqmc/t_api.git
# 切换(生成)虚拟环境
workon t_env
# 安装模块
pip3 install -r requirement.txt -i https://pypi.douban.com/simple
pip3 install uwsgi -i https://pypi.douban.com/simple
# uwsgi配置(配置在后面) 在项目根路径
vim t_api.xml
# nginx配置
cp /usr/local/nginx/conf/nginx.conf   /home/back.conf
vim /usr/local/nginx/conf/nginx.conf

t_api.xml

<uwsgi>    
           <socket>127.0.0.1:8888</socket>
           <chdir>/home/t_api</chdir>       
           <module>t_api.wsgi</module>
           <processes>4</processes>
           <daemonize>uwsgi.log</daemonize>
</uwsgi>

 nginx.conf

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    server {
        listen 80;
        server_name  127.0.0.1;
        charset utf-8;
        location / {
            root /home/dist;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
    }
    server {
            listen 8000;
            server_name  127.0.0.1;
            charset utf-8;
            location / {
               include uwsgi_params;
               uwsgi_pass 127.0.0.1:8888;
               uwsgi_param UWSGI_SCRIPT luffy_api.wsgi; 
               uwsgi_param UWSGI_CHDIR /home/project/luffy_api/;
            }
            location /static {
            alias /home/static;
        	}
        }
} 

start up

nginx
uwsgi -x t_api.xml

to kill

pkill -9 -f nginx
pkill -9 -f uwsgi

filter

 ps -aux |grep nginx
 ps -aux |grep uwsgi

Guess you like

Origin blog.csdn.net/qq_52385631/article/details/131646515