本文以 ubuntu为例说明 部署jeecg-cloud ## 安装java 1.1:下载安装包 1.2: 将文件放在/usr 目录 1.3:运行 tar -zxvf jdk-8u181-linux-x64.tar.gz 解压文件 1.4 环境变量 sudo vim /etc/profile 按i进入编辑模式。在文件结尾加入 export JAVA\_HOME=/usr/jdk1.8.0\_181 export JRE\_HOME=${JAVA\_HOME}/jre export CLASSPATH=.:${JAVA\_HOME}/lib:${JRE\_HOME}/lib:$CLASSPATH export JAVA\_PATH=${JAVA\_HOME}/bin:${JRE\_HOME}/bin export PATH=$PATH:${JAVA\_PATH} 按esc 退出编辑 输入:wq!保存并退出 sudo source /etc/profile 环境变量生效 输入java以及javac命令验证 永久生效 在~/.bashrc文件中添加以下代码 sudo source /etc/profile ## 安装redis sudo apt-get install redis-server 使用redis-server -v 来查看redis的版本 vim /etc/redis/redis.conf 修改配置文件 sudo service redis-server restart 重启 sudo service redis-server stop 停止 sudo service redis-server start 启动 systemctl restart redis-server.service ## 安装mysql sudo apt-get install mysql-server sudo netstat -tap | grep mysql 1.首先输入以下指令: sudo cat /etc/mysql/debian.cnf 运行截图如下: ![http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/3BEB5BEBB5744AA3A9C7D03F8BF96EA3/1484](http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/3BEB5BEBB5744AA3A9C7D03F8BF96EA3/1484) 2\. 再输入以下指令: sudo mysql -u debian-sys-maint -p //注意! //这条指令的密码输入是输入第一条指令获得的信息中的 password = ZCt7QB7d8O3rFKQZ 得来。 //请根据自己的实际情况填写! 运行截图如下:(注意! 这步的密码输入的是 ZCt7QB7d8O3rFKQZ,密码是由第一条指令获得的信息中的 password = ZCt7QB7d8O3rFKQZ 得来,每个人不一样,请根据自己的实际情况输入,输入就可以得到以下运行情况) ![http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/92DE01CF583849778FBA759D475AB053/1483](http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/92DE01CF583849778FBA759D475AB053/1483) 3\. 修改密码,本篇文章将密码修改成 root , 用户可自行定义。 use mysql; // 更改密码。 update mysql.user set authentication\_string=password('yangLingJyjava123') where user='root' and Host ='localhost'; update user set plugin="mysql\_native\_password"; flush privileges; ![http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/B4C53186E6884709964E997A3F233D3F/1485](http://note.youdao.com/yws/public/resource/5080e2f1d24021ddd1bdf8e185a9a2d6/xmlnote/B4C53186E6884709964E997A3F233D3F/1485) sudo /etc/init.d/mysql start|stop|restart|reload|force-reload|status mysql -u root -p 连接 create database cct character set utf8; 创建数据库 source 文件路径 导入 mysqldump -u dbuser -p dbname > 导出路径 导出 ## 安装rabbitmq 1.安装 sudo apt-get install rabbitmq-server 2\. 启动 /停止 service rabbitmq-server start /service rabbitmq-server stop 3\. 查看用户rabbitmqctl list\_users 4.查看插件 rabbitmq-plugins list 5.启用控制台 rabbitmq-plugins enable rabbitmq\_management 6.安装并启用死信插件 rabbitmq-plugins enable rabbitmq\_delayed\_message\_exchange 7、添加admin,并赋予administrator权限 添加admin用户,密码设置为springcluod。 sudo rabbitmqctl add\_user  springcluod springcluod 赋予权限 sudo rabbitmqctl set\_user\_tags springcluod administrator 赋予virtual host中所有资源的配置、写、读权限以便管理其中的资源 sudo rabbitmqctl  set\_permissions -p / springcluod '.\*' '.\*' '.\*' ## 安装Nacos 将nacos放到服务器上解压,删除 /data/nacos/data/derby-data 切换目录到bin 后台启动 nohup bash -f ./startup.sh -m standalone & 前台启动 bash -f ./startup.sh -m standalone 6、打包、启动java 将打包好的jar文件放到服务器上 后台启动 nohup java -jar integral-admin.jar & 前台启动 java -jar integral-admin.jar ## 安装nginx apt-get install libtool 2.安装pcre依赖库 sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev 3.安装zlib依赖库 apt-get install zlib1g-dev 4.安装ssl依赖库 apt-get install openssl 下载最新版本: wget http://nginx.org/download/nginx-1.15.4.tar.gz #解压: tar -zxvf nginx-1.15.4.tar.gz #进入解压目录: cd nginx-1.15.4 #配置: sudo ./configure --prefix=/usr/nginx --with-http\_ssl\_module #编辑nginx: sudo make #安装nginx: sudo make install 启动 sudo /usr/nginx/sbin/nginx -c /usr/nginx/conf/nginx.conf 停止 sudo /usr/nginx/sbin/nginx -s stop 重启 sudo /usr/nginx/sbin/nginx -s reopen ## 部署前台vue 1、在控制台终端输入npm run build 打包vue 将打包好的dist文件上传到服务器 2、配置nginx代理 ``` server{ server\_name admin.test.com; listen 80; index index.jsp; location / { root /usr/jf/dist/; index index.html index.htm; try\_files $uri $uri/ /index.html; } } ``` 重新加载nginx配置文件 /usr/local/nginx/sbin/nginx -s reload重新加载 nginx 配置 ### 网关https证书配置 ``` server { listen 443 ssl; server\_name sc.lvgnc.com; index index.html index.htm; ssl\_certificate /usr/jf/2987217\_sc.lvgnc.com.pem; ssl\_certificate\_key /usr/jf/2987217\_sc.lvgnc.com.key; ssl\_session\_timeout 5m; ssl\_ciphers ECDHE-RSA-AES128-GCM- SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl\_protocols TLSv1 TLSv1.1 TLSv1.2; ssl\_prefer\_server\_ciphers on; location / { proxy\_pass http://localhost:8888; # 内网IP 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\_set\_header X-Forwarded-Proto $scheme; } } ``` #网关 ``` server{ server\_name qixingqizhiapp.yanglingeducation.com; listen 80; index index.jsp; location / { proxy\_pass http://localhost:8888; 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\_set\_header X-Forwarded-Proto $scheme; } } ``` #后台页面 ``` server{ server\_name qixingqizhiapp.yanglingeducation.com; listen 80; index index.jsp; location / { root /usr/jf/dist/; index index.html index.htm; try\_files $uri $uri/ /index.html; } } ``` 重启脚本 ``` #!/bin/bash PID=$(ps -ef | grep jeecg-system.jar | grep -v grep | awk '{ print $2 }') if \[ -z "$PID" \] then echo Application is already stopped echo jeecg-system start... nohup java -jar /usr/ed/jeecg-system.jar & else echo jeecg-system close... echo kill $PID kill -9 $PID sleep 1s echo jeecg-system start... nohup java -jar /usr/ed/jeecg-system.jar & fi ```