0 environment

  • Server: Aliyun
  • The server operating system is centos
  • SSH: xshell
  • Backend language: Django (Documentation)
  • Python default: 3.6.8

1 mapping

Environment Foundation + Deployment process

2 XhSell Installation and Configuration

Xshell installation package + color scheme download

Xshell installation issues + color scheme

3 nginx installation

sudo yum install nginx -y
Copy the code

4 Nginx service configuration

  • Sudo systemctl enable nginx

  • Sudo systemctl start nginx

  • Sudo systemctl restart nginx

  • Sudo Systemctl reload nginx

  • Check the nginx status systemctl status nginx

  • Sudo systemctl stop nginx

5 Check whether nginx is started

1 Run the following command to query information

nginx -t



ps -ef | grep nginx



# Check by port

Netstat anp | grep: in Nginx running on the port



Use lsof

Lsof -i: indicates the port to run on Nginx

Copy the code
Nginx -t command
ps -ef | grep nginx
Netstat anp | grep: in Nginx running on the port
The lsof command

2 Page Verification

Enter the public IP address of Aliyun

6 nginx configuration

The configuration file

1 uwsgi_params

Nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf: nginx.conf

uwsgi_param  QUERY_STRING       $query_string;

uwsgi_param  REQUEST_METHOD     $request_method;

uwsgi_param  CONTENT_TYPE       $content_type;

uwsgi_param  CONTENT_LENGTH     $content_length;



uwsgi_param  REQUEST_URI        $request_uri;

uwsgi_param  PATH_INFO          $document_uri;

uwsgi_param  DOCUMENT_ROOT      $document_root;

uwsgi_param  SERVER_PROTOCOL    $server_protocol;

uwsgi_param  REQUEST_SCHEME     $scheme;

uwsgi_param  HTTPS              $https if_not_empty;



uwsgi_param  REMOTE_ADDR        $remote_addr;

uwsgi_param  REMOTE_PORT        $remote_port;

uwsgi_param  SERVER_PORT        $server_port;

uwsgi_param  SERVER_NAME        $server_name;

Copy the code

2 nginx.conf

vim /etc/nginx/nginx.conf

Front/back – end ports Add ports to the security group access rules of Ali Cloud

1 Back-end configuration

Sudo systemctl restart nginx

server {

    # front-end access to back-end port (8091)

    listen          8091;

Server_name 127.0.0.1;

    charset         utf-8;



    location /static {

        alias /var/program/myprojects/xxx/static;

    }



    # For file uploads

    location /upload {

        alias /var/program/myprojects/xxx/upload;

    }



    location / {

Uwsgi_pass 127.0.0.1:9090;

        include      /etc/nginx/uwsgi_params;

        # Error if not set to upload larger images

        client_max_body_size    20m;

    }

}

Copy the code

Access public IP address :8091/path? Parameters & parameters

2 Front-end Configuration

Sudo systemctl restart nginx is saved

server {

        listen      8080 default_server;

Server_name 127.0.0.1;

        location /{

          Go to the root directory of the front-end project, copy and paste the full path after root

          root   /var/program/frontend/xxx;

          index  index.html;

          client_max_body_size    10m;

        }



  include /etc/nginx/default.d/*.conf;



  error_page 404 /404.html;

      location = /40x.html {

  }



  error_page 500 502 503 504 /50x.html;

      location = /50x.html {

  }

}

Copy the code

Access public IP address :8080

summary

Nginx summary