部署项目

api部署

  1. 下载源码

    cd /home/source
    git clone https://gitee.com/beijing_hongye_huicheng/lilishop.git
    
  1. 编辑运行api的脚本

    #版本 注意,需要跟随版本号进行调整
    version=4.3
    #代码目录
    code_path=/home/source/lilishop
    #运行目录
    run_path=/home/source/api/
    
    mkdir -p ${code_path}
    mkdir -p ${run_path}
    cd ${code_path}
    git checkout master
    git pull
    mvn clean install -DskipTests
    
    ps -ef |grep java |grep buyer  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    ps -ef |grep java |grep seller  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    ps -ef |grep java |grep manager  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    ps -ef |grep java |grep common  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    ps -ef |grep java |grep consumer  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    ps -ef |grep java |grep im  |grep -v 'grep'|awk '{print $2}'  | xargs kill -9
    
    rm -rf ${run_path}*.jar
    mv ${code_path}/common-api/target/common-api-$version.jar ${run_path}
    mv ${code_path}/buyer-api/target/buyer-api-$version.jar ${run_path}
    mv ${code_path}/consumer/target/consumer-$version.jar ${run_path}
    mv ${code_path}/manager-api/target/manager-api-$version.jar ${run_path}
    mv ${code_path}/seller-api/target/seller-api-$version.jar ${run_path}
    mv ${code_path}/im-api/target/im-api-$version.jar ${run_path}
    
    cd ${run_path}
    
    mkdir logs
    
    nohup java -Xmx256m -Xms128m -Xss256k  -jar manager-api-$version.jar> logs/manager.out  &
    nohup java -Xmx256m -Xms128m -Xss256k  -jar common-api-$version.jar> logs/common.out  &
    nohup java -Xmx256m -Xms128m -Xss256k  -jar buyer-api-$version.jar> logs/buyer.out  &
    nohup java -Xmx256m -Xms128m -Xss256k  -jar consumer-$version.jar> logs/consumer.out  &
    nohup java -Xmx256m -Xms128m -Xss256k  -jar im-api-$version.jar> logs/im.out  &
    nohup java -Xmx256m -Xms128m -Xss256k  -jar seller-api-$version.jar> logs/seller.out  &
    
  1. 执行脚本

    chmod +x start-api.sh
    sh start-api.sh
    

前端部署

  1. 下载代码

    cd /home/source
    git clone https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
    
  2. 安装node yarn

    yum update
    yum install -y nodejs
    yum install -y npm
    npm install -g yarn
    #   #设置镜像
    #   yarn config set registry https://registry.npmmirror.com --global
    #   yarn config set disturl https://registry.npmmirror.com/dist --global
    
    # 升级node
    npm install -g n
    n install v14.16.0
    
  1. 编辑脚本

    #代码目录
    code_path=/home/source/lilishop-ui
    
    cd ${code_path}
    git checkout master
    git pull
    
    cd ${code_path}/manager
    yarn install
    yarn build
    
    cd ${code_path}/seller
    yarn install
    yarn build
    
    cd ${code_path}/buyer
    yarn install
    yarn build
    
  1. 执行脚本

    chmod +x start-ui.sh
    sh start-ui.sh
    
  1. h5部署没有技巧,需要从hbuilder中导出h5,复制到目录:/home/source/h5

  2. 安装nginx

    sudo yum install -y nginx
    
  3. Nginx 示例配置文件

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
        proxy_hide_header X-Powered-By;
        proxy_hide_header Server;
        # 开启gzip
        gzip on;
    
        # 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
        gzip_min_length 1k;
    
        # gzip 压缩级别 1-10 
        gzip_comp_level 2;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
      #http强制跳转 https
        server {
             listen 80;
             server_name pickmall.cn;
             rewrite ^(.*)$  https://$host$1 permanent;
             location ~ / {
                index index.html index.php index.htm;
             }
     }
    
        #管理端
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            server_name  admin-b2b2c.pickmall.cn;
            try_files $uri $uri/ /index.html;
    
            root    /home/source/lilishop-ui/manager/dist;
        }
    
        #商家端
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            server_name  store-b2b2c.pickmall.cn;
            try_files $uri $uri/ /index.html;
            root    /home/source/lilishop-ui/seller/dist;
        }
    
        #h5端
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            server_name  m-b2b2c.pickmall.cn;
            try_files $uri $uri/ /index.html;
            root    /home/source/h5;
        }
    
        #PC端
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            server_name  pc-b2b2c.pickmall.cn;
            try_files $uri $uri/ /index.html;
            root         /home/source/lilishop-ui/buyer/dist;
        }
        #IM
         server {
             listen       443 ssl;
             ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
             ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
             ssl_session_cache shared:SSL:1m;
             ssl_session_timeout  10m;
             ssl_ciphers HIGH:!aNULL:!MD5;
             ssl_prefer_server_ciphers on;
          include /etc/nginx/default.d/*.conf;
    
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header REMOTE-HOST $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
             server_name  im.pickmall.cn;
             try_files $uri $uri/ /index.html;
             root         /home/source/lili-shop-ui/im/dist;
         }
    
        #common-api
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            server_name  common-api.pickmall.cn;
            location / {
                proxy_pass http://127.0.0.1:8890;
            }
        }
        #admin-api
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
            server_name  admin-api.pickmall.cn;
            location / {
                proxy_pass http://127.0.0.1:8887;
            }
        }
        #buyer-api
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
            server_name  buyer-api.pickmall.cn;
            location / {
                proxy_pass http://127.0.0.1:8888;
            }
        }
         #store-api
        server {
            listen       443 ssl;
            ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
            ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
            ssl_session_cache shared:SSL:1m;
            ssl_session_timeout  10m;
            ssl_ciphers HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers on;
            include /etc/nginx/default.d/*.conf;
    
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
            server_name  store-api.pickmall.cn;
            location / {
                proxy_pass http://127.0.0.1:8889;
            }
        }
         #im-api
         server {
             listen       443 ssl;
             ssl_certificate "/etc/nginx/ssl/pickmall.cn.pem";
             ssl_certificate_key "/etc/nginx/ssl/pickmall.cn.key";
             ssl_session_cache shared:SSL:1m;
             ssl_session_timeout  10m;
             ssl_ciphers HIGH:!aNULL:!MD5;
             ssl_prefer_server_ciphers on;
             include /etc/nginx/default.d/*.conf;
             server_name  im-api.pickmall.cn;
    
             location / {
                 proxy_http_version 1.1;    
                 proxy_set_header Upgrade $http_upgrade;    
                 proxy_set_header Connection "Upgrade";    
                 proxy_set_header X-real-ip $remote_addr;
                 proxy_set_header X-Forwarded-For $remote_addr;
                 proxy_pass http://127.0.0.1:8885;
             }
         }
    
    }
    
  1. nginx 启动

    service nginx restart
    

维护

代码更新部署
   cd /home/source
   sh start-api.sh
   sh start-ui.sh
   #h5 没有捷径,需要导出然后复制到线上对应目录

results matching ""

    No results matching ""