uWSGI Django deployment of on-line

Environment:
  . 1 .CentOS 7.2 64 bit
  2 the .SQL 2016 Enterprise Server 64 bit
  . 3 .Python bit 64 3.6.5
  . 4 .Root user

Requirements:
  Deployment order

1 install the database at .Windows Server 2016 Datacenter 64-bit operating system

2 .CentOS 7.2 under the   Python environment to build

3 Install ODBC for SQL Server

. 1 curl HTTPS: // packages.microsoft.com/config/rhel/7/prod.repo> /etc/yum.repos.d/mssql-release.repo 
2  yum Remove the unixODBC-UTF16 utf16- the unixODBC- devel
 . 3 ACCEPT_EULA = the Y yum  the install msodbcsql
 . 4  yum  the install unixODBC- devel
 . 5  
. 6  # the following three lines are connected to the database installation tool, with less general item
 . 7 ACCEPT_EULA the Y = yum  the install mssql- tools
 . 8  LN -s / opt / MSSQL-tools / bin / BCP / usr / bin / BCP
 . 9  LN -s / opt / MSSQL-Tools / bin / the sqlcmd / usr / bin / the sqlcmd
 10 
11  # The following is a Django settings.py configuration database
 12 is DATABASES = {
 13 is      ' default ' : {
 14          ' ENGINE ' : ' sql_server.pyodbc ' ,
 15          ' NAME ' : ' DB ' ,
 16          ' the USER ' : ' User ' ,
 . 17          ' PASSWORD ' : ' pwd ' ,
 18 is          ' the HOST ' : 'ip',
19         'PORT': '1433',
20         'OPTIONS': {
21             'driver': 'ODBC Driver 13 for SQL Server',
22         },
23     },
24 }
25 
26 DATABASE_CONNECTION_POOLING = True

4 . Uwsgi installation and uwsgitop (see tool uwsgi state, if securecrt CentOS connected, the terminal needs to set the xterm)

. 1 PIP the install to uwsgi uwsgitop
 2  
. 3  # to uwsgi configured as follows:
 . 4  [to uwsgi]
 . 5 socket = / SRV / WWW / uwsgi.sock # using socket communication
 . 6 Master = to true 
. 7 Processes = . 4 # of processes. 4, generally in accordance with the number of CPU provided
 8 threads = 5 # 5 threads per process
 9 enable-threads = to true # due to limitations Python's GIL, less useful, not been tested, or open
 10 chdir = / SRV / the WWW project root directory #
 11 wsgi- File = / SRV / WWW / Project / wsgi.py
 12 is stats = / SRV / WWW /uwsgi.stats # uwsgitop with use commands: uwsgitop uwsgi.stats view status
 13 is PidFile = /srv/www/uwsgi.pid #uwsgi --stop uwsgi.pid; to uwsgi - reload uwsgi.pid
 14 to daemonize = / SRV / WWW / uwsgi.log # log
 15 log-MAXSIZE = 10000000 
16 disable the logging =- to true not record the log # open request
 . 17 Vacuum = to true clean off #uwsgi relevant file
 18 is # the chmod -socket = 644 
. 19 # CHROOT 
20 is  #GID
 21 is #uid

5 Install nginx

 1 tar -zxvf nginx-1.16.1.tar.gz
 2 cd nginx-1.16.1/
 3 ./configure --prefix=/opt/nginx
 4 make && make install
 5 ln -s /opt/nginx/sbin/ /usr/bin/nginx
 6 # nginx.conf配置如下:
 7 #user  nobody;
 8 worker_processes  4;
 9 
10 #error_log  logs/error.log;
11 #error_log  logs/error.log  notice;
12 #error_log  logs/error.log  info;
13 
14 pid        logs/nginx.pid;
15 
16 
17 events {
18     worker_connections  1024;
19 }
20 
21 http {
22     include       mime.types;
23     default_type  application/octet-stream;
24 
25     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
26                       '$status $body_bytes_sent "$http_referer" '
27                       '"$http_user_agent" "$http_x_forwarded_for"';
28 
29     sendfile        on;
30     keepalive_timeout  65;
31 
32     gzip  on;
33 
34     server {
35         listen       80;
36         server_name  192.168.70.110;
37         charset utf-8;
38         access_log  logs/host.access.log  main;
39         client_max_body_size 100M;
40 
41         location /{Media
 42 is              Alias / SRV / WWW / Media;
 43 is          }
 44 is      
45          LOCATION / static {
 46 is              Alias / SRV / WWW / static;
 47          }
 48  
49          LOCATION / {
 50              uwsgi_pass UNIX: /// SRV / WWW / uwsgi.sock; 
51 is              the include / SRV / WWW / uwsgi_params; # file nginx / conf directory, items can be copied to the folder
 52 is          }
 53 is  
54 is          error_page   404               / 404 .html;
 55      }
56 }

6 . Start

1 uwsgi /path/to/uwsgi.ini && nginx

7 . Installation supervisor

Guess you like

Origin www.cnblogs.com/Siriusmath/p/11433117.html