Skip to content

项目线上部署配置

Fighter edited this page Jul 4, 2019 · 2 revisions

前端部署使用Nginx

  • 前端部署到线上一般是执行npm run build打包,打包后nginx作为web服务器加载静态目录
# Ngninx 配置

server {
    listen 80 default_server;
    server_name localhost;

    access_log  /var/log/nginx/spug.access.log  main;
    error_log  /var/log/nginx/spug.error.log;

    # gzip config
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

    location /api/ {
        rewrite ^/api(.*)$ $1 break;
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   X-Real-IP         $remote_addr;
    }

    location / {
        root /www/spug_web/dist;
    }
    error_page 404 =200 /index.html;
}

后端启动

  • 线上后端启动可以选择使用gunicorn或者uwsgi启动
# gunicornq启动:

shell> pip install gunicorn
shell> gunicorn -D --chdir=/www/spug_api/ --access-logfile=/var/log/spug_access.log  --log-file=/var/log/spug.log  --error-logfile=/var/log/spug_error.log --threads=32 main:app -b 0.0.0.0:3000
Clone this wiki locally