前后端分离之项目部署

编辑于 2021-05-21 09:49:20 阅读 2125

前后端分离的架构模式被越来越多的中大型项目所采用,这就给项目部署提出了要求

需求

假如有这么一个系统

nginx配置

xx.com.conf

server {
    listen       80;
    server_name  xx.com; # 用户端
    index index.php index.htm index.html default.html;
    root      /data/www/shop-h5/web;

    # 服务端
    location /api {
        proxy_pass   http://127.0.0.1:8089/;
        include conf.d/proxy.md;
    }
    # 管理员端
    location /admin/ {
        alias  /data/www/shop-admin/web/;
        break;
    }

}

xx8089.conf

server {
    listen 8089;
    index default.html index.htm index.html index.php; 
    root /data/www/shop/web;

    rewrite ^/admin/(.*)$ /admin.php/admin/$1 last;
    rewrite ^/user/(.*)$ /user.php/user/$1 last;

    location ~ \.php {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param ENV_MODE production;
        include        fastcgi_params;
    }

}

广而告之,我的新作品《语音助手》上架Google Play了,欢迎下载体验