部署项目
上线准备
一套完整的域名(PC端、移动端、商家端、管理端、以及4个API端)
ssl证书
域名备案
支付宝支付参数
微信支付参数
微信联合登陆参数
阿里云OSS参数
阿里云短信参数
快递鸟物流查询参数
最低服务器配置
4核32G内存服务器一台(推荐使用 CentOS 7.6 64位)(如果基础中间件使用外部服务器的,则可以适量减少内存)
环境准备
jdk 8/jdk 17 (jdk 17 启动服务时需要增加启动参数 '--add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED')
Mysql 8.0.25
Redis 6.2.6
elasticsearch 7.17.5 需要IK分词器
rocket-server 4.9.2
xxl-job 2.3.0
nacos 2.3.0
seata 1.5.2
以上环境为演示站点环境,尽可能使用同一版本
中间件(如果自行部署基础中间件,则可以略过这里,这里主要安装基础中间件)
kubernates
https://gitee.com/beijing_hongye_huicheng/docker/tree/micro/kubernetes
docker-compose(已经安装的可以略过)
# 安装git
sudo yum install -y git
# 安装maven
sudo yum install -y maven
# 安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 设置源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
# 安装docker
sudo yum install -y docker-ce
# 启动服务
sudo systemctl start docker
# 安装docker-compose
curl -L https://github.com/docker/compose/releases/download/v2.17.1/docker-compose-linux-x86_64 > /usr/local/bin/docker-compose
# 授权
sudo chmod +x /usr/local/bin/docker-compose
# 检测版本号
docker-compose -v
docker脚本下载
git clone -b micro https://gitee.com/beijing_hongye_huicheng/docker.git
修改配置
- Rocketmq 需要特殊配制一下节点ip 在 config/broker.conf 文件中,将brokerIP1修改为部署docker的局域网ip
- Rocketmq 和 Elasticsearch 映射本地目录权限一定要设置为 777 权限,否则启动不成功
运行脚本(第一行为部署环境包括Mysql、mq、redis、xxljob等所有中间健)
docker-compose up -d
校验(查看进程是否启动,如果反复启动的程序,可以使用docker logs 镜像id 查看日志)
docker ps
api部署
执行项目根目录脚本
chmod +x start-api.sh sh start-api.sh
前端部署
编译
安装node yarn
yum update yum install -y nodejs 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 lts
执行项目根目录脚本
chmod +x build.sh.sh sh build.sh.sh
- h5部署没有技巧,需要从hbuilder中导出h5,复制到目录:/home/source/h5
部署
nginx
安装nginx
yum install -y nginx
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; #管理端 server { listen 443 ssl; ssl_certificate "/etc/nginx/ssl/xxx.cn.pem"; ssl_certificate_key "/etc/nginx/ssl/xxx.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.xxx.cn; try_files $uri $uri/ /index.html; root /home/source/ui/manager/dist; } #商家端 server { listen 443 ssl; ssl_certificate "/etc/nginx/ssl/xxx.cn.pem"; ssl_certificate_key "/etc/nginx/ssl/xxx.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.xxx.cn; try_files $uri $uri/ /index.html; root /home/source/ui/seller/dist; } #h5端 server { listen 443 ssl; ssl_certificate "/etc/nginx/ssl/xxx.cn.pem"; ssl_certific#商家端ate_key "/etc/nginx/ssl/xxx.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.xxx.cn; try_files $uri $uri/ /index.html; root /home/source/h5; } #PC端 server { listen 443 ssl; ssl_certificate "/etc/nginx/ssl/xxx.cn.pem"; ssl_certificate_key "/etc/nginx/ssl/xxx.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.xxx.cn; try_files $uri $uri/ /index.html; root /home/source/lilishop-ui/buyer/dist; } #api-gateway server { listen 443 ssl; ssl_certificate "/etc/nginx/ssl/xxx.cn.pem"; ssl_certificate_key "/etc/nginx/ssl/xxx.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 api.xxx.cn; location / { proxy_pass http://127.0.0.1:8888; } } }
nginx 启动
service nginx restart