统一用户+cas部署
<p>[TOC]</p>
<h3>部署拓扑图</h3>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/0a046489ede08eb01e6a678a3bee0897" alt="" /></p>
<h3>MySQL部署</h3>
<p>具体部署过程请参考文档:[Linux手动安装MySQL](<a href="http://60.191.64.5:16100/web/#/p/6a9024b4c223d214a99eac3076d932c3">http://60.191.64.5:16100/web/#/p/6a9024b4c223d214a99eac3076d932c3</a> "Linux系统安装MySQL")
MySQL驱动替换方法:</p>
<pre><code class="language-shell">项目包数据库驱动位置:/WEB-INF/lib/
将旧驱动移至备份目录,将新驱动上传至此目录即可。如下图所示</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/2213bf95edfd1f2a0a9f7172d70188a1" alt="" /></p>
<ul>
<li>导入SQL数据库
<pre><code class="language-shell">chown -R mysql.mysql /home/mysql/dev.sql # 将文件上传至mysql用户家目录并修改文件属组
mysql -u root -p # 登陆数据库
mysql&gt; create database risen_typt DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; # 创建新库risen_typt,并设定库字符集格式为utf-8
mysql&gt; create user 'risen_typt'@'%' identified by 'Trl+A4.kFG'; # 创建普通用户risen_typt并设置密码
mysql&gt; grant all on risen_typt.* to 'risen_typt'@'%'; # 将risen_typt库所有权限赋予于给用户risen_typt
mysql&gt; use risen_typt; # 进入risen_typt库
mysql&gt; source /home/mysql/dev.sql; # 扫描并导入绝对路径下的sql数据文件,文件较大,等ing...</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/8936502c363f46ab789ae583c27da21b" alt="" /></p></li>
</ul>
<h3>安装JDK</h3>
<pre><code class="language-shell">mkdir -p /risen/soft/jdk # jdk安装目录
tar -zxf jdk-8u221-linux-x64.tar.gz
mv jdk1.8.0_221/ /risen/soft/jdk/jdk1.8
vim /etc/profile # 修改系统环境变量
export JAVA_HOME=/risen/soft/jdk/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile # 使刚修改的环境变量即刻生效
java -version</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/7734a108b12e95c1b4b8fa500c32799b" alt="" /></p>
<h3>安装Nginx</h3>
<p>具体安装请参考文档:[Linux系统安装Nginx](<a href="http://60.191.64.5:16100/web/#/p/7bd007a3e8001dc48290200dae8b716d">http://60.191.64.5:16100/web/#/p/7bd007a3e8001dc48290200dae8b716d</a> "Linux系统安装Nginx")
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/a4d23d3d23af44cbdf5c32468eb45b4a" alt="" /></p>
<h4>配置Nginx</h4>
<p>点击下载:[nginx.conf](<a href="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/b5cf2c471ecae4668ffdb4fe42f3e9d2">http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/b5cf2c471ecae4668ffdb4fe42f3e9d2</a> "[nginx.conf")</p>
<pre><code class="language-shell">vim /risen/soft/nginx/conf/nginx.conf
server {
listen 80; # nginx访问端口
server_name localhost;
# 统一平台访问地址
location /typt {
proxy_pass http://127.0.0.1:8080/typt; # 统一平台后端地址
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 统一平台接口地址
location /typt/api {
proxy_pass http://127.0.0.1:8080/typt;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 统一平台静态页
location /typt/web {
alias /risen/soft/tomcat/tomcat_typt_8080/webapps/typt/static;
}
# cas访问地址
location /cas {
proxy_pass http://127.0.0.1:8081/cas; # 后端cas访问地址
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 403 500 502 503 504 /404.html;
location = /404.html {
root html;
}
}</code></pre>
<h3>安装tomcat</h3>
<pre><code class="language-shell">mkdir -p /risen/soft/tomcat # 创建tomcat安装目录
unzip apache-tomcat-8.5.75.zip # 解压tomcat压缩文件
chmod +x apache-tomcat-8.5.75/bin/*.sh # 赋予执行权限
cp -a apache-tomcat-8.5.75 /risen/soft/tomcat/tomcat_typt_8080
vim apache-tomcat-8.5.75/conf/server.xml # 避免端口冲突需要修改默认端口,两处,详见下图二图三
mv apache-tomcat-8.5.75 /risen/soft/tomcat/tomcat_cas_8081</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/761e40be6e1a17f464b5746e228a4950" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/1d09d5d55992580a2ea3a965983b4d23" alt="" />
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/3bbd4f7c01a9b42c2ecffc146b17dc5b" alt="" /></p>
<h4>上传项目包</h4>
<ul>
<li>修改统一平台项目包文件
数据库配置文件:<code>typt.war/WEB-INF/classes/com/risen/base/config/connection.properties</code>
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/d0df4dc627304d3163fe9b9096fcc2e5" alt="" />
跳转地址配置文件:<code>typt.war/WEB-INF/classes/com/risen/base/config/view-extend-app.properties</code>
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/ab11b4616a39eab691955333cc13c48d" alt="" />
CAS调用地址文件:<code>typt.war/WEB-INF/web.xml</code>
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/f3f3f4ef8b447962a2e1b24801fdaf47" alt="" /></li>
<li>修改cas项目包文件
数据库配置文件:<code>cas.war/WEB-INF/cas.properties</code>
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/3102900354460eb6b9a85ba2ae496f85" alt="" /></li>
<li>将各自项目war包放至对应tomcat的webapps目录下
<pre><code class="language-shell">mv cas.war /risen/soft/tomcat/tomcat_cas_8081/webapps/
mv typy.war /risen/soft/tomcat/tomcat_typt_8080/webapps/</code></pre>
<h4>启动CAS</h4>
<pre><code class="language-shell">cd /risen/soft/tomcat/tomcat_cas_8081/bin/
./startup.sh # 启动
./shutdown.sh # 关闭
ps -ef | grep java # 查看服务进程
tail -f /risen/soft/tomcat/tomcat_cas_8081/logs/catalina.out # 查看实时日志</code></pre>
<p><img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/1d1f5cc0e2f307a11d3f7f4b1e55638b" alt="" />
浏览器访问:<a href="http://IP:nginx端口/cas">http://IP:nginx端口/cas</a>
(访问cas后缀就加cas,其他项目同理,也可在nginx配置不加后缀)
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/cd6312344493cb5f19deec5bad30e6ef" alt="" /></p>
<h4>启动统一平台</h4>
<pre><code class="language-shell">cd /risen/soft/tomcat/tomcat_typt_8080/bin/
./startup.sh # 启动
./shutdown.sh # 关闭
ps -ef | grep java # 查看服务进程
tail -f /risen/soft/tomcat/tomcat_typt_8080/logs/catalina.out # 查看实时日志</code></pre>
<p>浏览器访问:<a href="http://IP:nginx端口/typt">http://IP:nginx端口/typt</a>
(因为上面登陆了cas,这里回车直接免密登陆)
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/56b7ccadacfaa9c5964a7ceb8c878c51" alt="" /></p>
<h4>统一用户修改跳转地址</h4>
<p>1.登陆成功后将连接地址中的home改成super
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/4bc007b6b3164be97331d68aff92a771" alt="" />
2.进入后台后依次点击:统一用户 > 外部业务系统 > 统一用户后台编辑
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/3cf5a9c3c89eee0fc7ac19053e3fb7ae" alt="" />
3.基础信息 > 入口地址修改
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/ff9d447cba549fab3bebaa064f9d61fc" alt="" />
4.开放授权 > 回调地址修改 > 保存
<img src="http://60.191.64.5:16100/server/index.php?s=/api/attachment/visitFile/sign/cdcd326fed5786c75bc3aa3ef19ba917" alt="" /></p></li>
</ul>