项目部署

项目部署

服务器要求

Linux Centos7、4核8G、5M带宽、硬盘300G

软件安装

1、docker安装

    参考  [https://www.runoob.com/docker/centos-docker-install.html]
    设置docker开机自启动 sudo systemctl enable docker

2、安装Mysql5.6

    cd /usr/local/docker/mysql
    参考  [https://www.runoob.com/docker/docker-install-mysql.html]
	docker run -p 3306:3306 --name mysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=***** -e TZ=Asia/Shanghai -d mysql:5.6
    手动修改mysql容器的时区
		docker cp mysql:/etc/mysql/mysql.conf.d/mysqld.cnf mysqld.cnf 
		vim mysqld.cnf 
		在 [mysqld] 节点下添加一行
		default-time-zone = '+08:00'   保存退出
		docker cp mysqld.cnf mysql:/etc/mysql/mysql.conf.d/mysqld.cnf
	手动修改mysql表名忽略大小写
		docker cp mysql:/etc/mysql/mysql.conf.d/mysqld.cnf mysqld.cnf 
		vim mysqld.cnf 
		在 [mysqld] 节点下添加一行
		lower_case_table_names=1   保存退出
		docker cp mysqld.cnf mysql:/etc/mysql/mysql.conf.d/mysqld.cnf
		重启mysql容器
	设置mysql容器 开机自启动  docker update --restart always mysql

3、安装Redis

    cd /usr/local/docker/redis
    参考  [https://www.runoob.com/docker/docker-install-redis.html]
    docker run -p 6379:6379 -v $PWD/data:/data --name=redis --restart=always -d redis redis-server --appendonly yes --requirepass "*****" 
    设置redis容器 开机自启动  docker update --restart always redis

4、安装nginx

    cd /usr/local/docker/nginx
    参考  [https://www.runoob.com/docker/docker-install-nginx.html]
    docker run -d -p 80:80 -p 443:443 --name nginx -v $PWD/ssl:/ssl -v $PWD/www:/usr/share/nginx/html -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/var/log/nginx nginx
    docker run -d -p 80:80 -p 443:443 -p 8081:8081 -p 8082:8082 -p 8083:8083 --name nginx -v $PWD/ssl:/ssl -v $PWD/www:/usr/local/docker/nginx/html -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/var/log/nginx nginx
    设置nginx容器 开机自启动  docker update --restart always nginx

5、SSL证书配置

    将ssl证书放入文件夹 /usr/local/docker/nginx/ssl/bbalt/2019
    配置  nginx.conf,配置文件如下
	
	upstream bbalt_webapi_stream {
		ip_hash;
		server  172.31.225.210:8088;
	}
	
	server {
		listen 80;
	#	listen [::]:80;
		charset utf-8;
		server_name guanliapi.bbalt.org;

		access_log /var/log/nginx/bbalt/webapi/access.log ;
		error_log /var/log/nginx/bbalt/webapi/error.log info;

		# rewrite ^/$ / permanent;

		location / {
				proxy_pass        http://bbalt_webapi_stream;
				proxy_set_header   Host            $host;
				proxy_set_header   X-Real-IP        $remote_addr;
				proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
				proxy_send_timeout 600s;
				proxy_read_timeout 600s;
		}
	}
	
	upstream bbalt_donateapi_stream {
		ip_hash;
		server  172.31.225.210:8086;
	}
	
	server {

		listen 443 ssl;
		server_name juanyi.bbalt.org;

		proxy_set_header X-Forwarded-Proto https;
		# ssl on;
		ssl_certificate /ssl/bbalt/2019/2283958_juanyi.bbalt.org.pem;
		ssl_certificate_key /ssl/bbalt/2019/2283958_juanyi.bbalt.org.key;

		access_log /var/log/nginx/bbalt/donateapi/access.log ;
		error_log /var/log/nginx/bbalt/donateapi/error.log info;


		ssl_session_timeout  5m;
		ssl_protocols SSLv3 TLSv1 TLSv1.2;
		ssl_ciphers  HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
		ssl_prefer_server_ciphers   on; 
		
		client_max_body_size     50m;

		location / {
			
		#	rewrite ^/$ /misApi permanent;
				
			proxy_pass        http://bbalt_donateapi_stream;

			set $fixed_destination $http_destination;
			if ( $http_destination ~* ^https(.*)$ )
			{
				set $fixed_destination http$1;
			}

			proxy_set_header   Host             $host;
			proxy_set_header   X-Real-IP        $remote_addr;
			proxy_set_header   X-Forward-For    $remote_addr;
			proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_set_header   Destination $fixed_destination;
			
			proxy_connect_timeout       600;
			proxy_read_timeout          600;
			proxy_send_timeout          600;
			proxy_store         off;
			proxy_redirect      off;

		}
		error_page  500 502 503 504  /50x.html;
		location = /50x.html {
			root   html;
		}
	}
	
	upstream bbalt_zhijianapi_stream {
		ip_hash;
		server  172.31.225.210:8087;
	}
	
	server {

		listen 443 ssl;
		server_name zhiyuan.bbalt.org;

		proxy_set_header X-Forwarded-Proto https;
		# ssl on;
		ssl_certificate /ssl/bbalt/2019/2283945_zhiyuan.bbalt.org.pem;
		ssl_certificate_key /ssl/bbalt/2019/2283945_zhiyuan.bbalt.org.key;

		access_log /var/log/nginx/bbalt/zhijianapi/access.log ;
		error_log /var/log/nginx/bbalt/zhijianapi/error.log info;


		ssl_session_timeout  5m;
		ssl_protocols SSLv3 TLSv1 TLSv1.2;
		ssl_ciphers  HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
		ssl_prefer_server_ciphers   on; 
		
		client_max_body_size     50m;

		location / {
			
		#	rewrite ^/$ /misApi permanent;
				
			proxy_pass        http://bbalt_zhijianapi_stream;

			set $fixed_destination $http_destination;
			if ( $http_destination ~* ^https(.*)$ )
			{
				set $fixed_destination http$1;
			}

			proxy_set_header   Host             $host;
			proxy_set_header   X-Real-IP        $remote_addr;
			proxy_set_header   X-Forward-For    $remote_addr;
			proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_set_header   Destination $fixed_destination;
			
			proxy_connect_timeout       600;
			proxy_read_timeout          600;
			proxy_send_timeout          600;
			proxy_store         off;
			proxy_redirect      off;

		}
		error_page  500 502 503 504  /50x.html;
		location = /50x.html {
			root   html;
		}
	}
	
	server {
		listen 80;
		server_name guanli.bbalt.org;

		error_page 500 502 503 504 /50x.html;
		
		root /www/bbalt/web/dist;
		index index.html;

		location / {
			root /usr/share/nginx/html/bbalt/web/dist;
			index       index.html;
			try_files $uri $uri/ /index.html;
		}

		location @router {
			rewrite ^.*$ /index.html last;
		}
		
		error_page  500 502 503 504  /50x.html;
		location = /50x.html {
			root   html;
		}
	}

6、后台管理前端发布

    创建目录 /home/bbalt/web/dist
	将管理端打包后的dist中的文件拷贝到 /home/bbalt/web/dist 目录下
	重启nginx容器:  docker restart nginx

7、捐衣接口发布

    创建目录 mkdir /home/bbalt/api/donateapi
	将 donate-api-1.0.jar  cp到该目录下
	创建启动脚本 restart.sh
	脚本内容如下:
		#!/bin/bash
		export LANG="en_US.UTF-8"
		DIR=/home/bbalt/api/donateapi
		NAME=donate-api-1.0.jar
		echo "---------------"
		echo "重启捐衣Api"
		ID=`ps -ef|grep $NAME|grep -v grep|awk '{print $2}' `
		echo $ID
		if [ -z "${ID}" ]; then
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目未启动,直接启动"
		else
			kill -9 $ID
			echo "killed $id"
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目已启动,重新启动"
		fi
		echo "---------------"
		exit 0;
	赋予脚本权限:chmod 777 restart.sh 	
	启动项目:
		cd /home/bbalt/api/donateapi
		./restart.sh 	

8、 后台管理接口发布

    创建目录 mkdir /home/bbalt/api/webapi
	将 web-api-1.0.jar  cp到该目录下
	创建启动脚本 restart.sh
	脚本内容如下:
		#!/bin/bash
		export LANG="en_US.UTF-8"
		DIR=/home/bbalt/api/webapi
		NAME=web-api-1.0.jar
		echo "---------------"
		echo "重启后台管理Api"
		ID=`ps -ef|grep $NAME|grep -v grep|awk '{print $2}' `
		echo $ID
		if [ -z "${ID}" ]; then
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目未启动,直接启动"
		else
			kill -9 $ID
			echo "killed $id" 
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目已启动,重新启动"
		fi
		echo "---------------"
		exit 0;
	赋予脚本权限:chmod 777 restart.sh
	启动项目:		
		cd /home/bbalt/api/webapi
		./restart.sh 

9、质检接口发布

    创建目录 mkdir /home/bbalt/api/zhijianapi
	将 quality-inspection-api-1.0.jar  cp到该目录下
	创建启动脚本 restart.sh
	脚本内容如下:
		#!/bin/bash
		export LANG="en_US.UTF-8"
		DIR=/home/bbalt/api/zhijianapi
		NAME=quality-inspection-api-1.0.jar
		echo "---------------"
		echo "重启质检Api"
		ID=`ps -ef|grep $NAME|grep -v grep|awk '{print $2}' `
		echo $ID
		if [ -z "${ID}" ]; then
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目未启动,直接启动"
		else
			kill -9 $ID
			echo "killed $id" 
			cd $DIR
			source /etc/profile; nohup java -Djasypt.encryptor.password=RmqkE9GbuhWEv8JcD1BRxBu980lZWG2s -jar $NAME > catalina.out  2>&1 &
			echo "项目已启动,重新启动"
		fi
		echo "---------------"
		exit 0;
	赋予脚本权限:chmod 777 restart.sh 
	启动项目:		
		cd /home/bbalt/api/webapi
		./restart.sh 

安装 MariaDB

	docker pull mariadb
	docker run -p 3308:3306 --name mariadb -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Hans$%^888 -e TZ=Asia/Shanghai -d mariadb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值