CAS-Centos7安装CAS服务端
环境信息
[root@suhw ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@suhw ~]# uname -a
Linux suhw 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
安装jdk
查看系统信息
[root@suhw ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@suhw ~]# uname -a
Linux suhw 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
查看yum
包含的jdk
版本
[root@suhw ~]# yum search java
安装jdk
[root@suhw ~]# yum install java-1.8.0-openjdk-devel.x86_64
环境变量配置
将以下三行内容写入/etc/profile
中,JAVA_HOME
以实际为准
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
安装校验
[root@suhw ~]# source /etc/profile
[root@suhw ~]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
安装Tomcat
下载
[root@suhw ~]# cd /usr/local/
[root@suhw local]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.55/bin/apache-tomcat-8.5.55.tar.gz
解压
[root@suhw local]# tar -zxvf apache-tomcat-8.5.55.tar.gz
# 修改名称
[root@suhw local]# mv apache-tomcat-8.5.55 tomcat
启动
[root@suhw ~]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
关闭
[root@suhw ~]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
测试
查看默认端口是否监听
[root@suhw tomcat]# lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 9233 root 52u IPv6 62224 0t0 TCP *:webcache (LISTEN)
默认端口配置在/usr/local/tomcat/conf/server.xml
中
69 <Connector port="8080" protocol="HTTP/1.1"
70 connectionTimeout="20000"
71 redirectPort="8443" />
访问ip:port
,出现下图即为配置成功
注:可能需要关闭防火墙
[root@suhw tomcat]# firewall-cmd --state
running
[root@suhw tomcat]# systemctl stop firewalld.service
CAS
安装
下载
下载地址
https://github.com/apereo/cas/releases/tag/v4.0.0
解压
[root@suhw ~]# unzip cas-server-4.0.0-release.zip
[root@suhw ~]# cd cas-server-4.0.0/modules/
# 重命令为 cas.war
[root@suhw modules]# mv cas-server-webapp-4.0.0.war cas.war
# 将cas.war 拷贝至 tomcat/webapps/ 下
[root@suhw modules]# cp cas.war /usr/local/tomcat/webapps/
配置
tomcat
会自动解析war
包,构建web
项目cas
[root@suhw ~]# ll /usr/local/tomcat/webapps/
total 24460
drwxr-x---. 7 root root 108 Jun 3 12:05 cas
-rw-r--r--. 1 root root 25038970 Jun 3 12:05 cas.war
drwxr-x---. 16 root root 4096 Jun 3 11:12 docs
drwxr-x---. 6 root root 83 Jun 3 11:12 examples
drwxr-x---. 5 root root 87 Jun 3 11:12 host-manager
drwxr-x---. 5 root root 103 Jun 3 11:12 manager
drwxr-x---. 3 root root 283 Jun 3 11:12 ROOT
端口修改
[root@suhw ~]# vi /usr/local/tomcat/webapps/cas/WEB-INF/cas.properties
确保 cas
与tomcat
端口一致
20 server.name=http://localhost:8080
21 server.prefix=${server.name}/cas
去除https
校验
cas
默认使用https
模式,由于没配置证书,所以取消https
1、修改/usr/local/tomcat/webapps/cas/WEB-INF/deployerConfigContext.xml
末尾增加p:requireSecure="false"
90 <!-- Required for proxy ticket mechanism. -->
91 <bean id="proxyAuthenticationHandler"
92 class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
93 p:httpClient-ref="httpClient" p:requireSecure="false" />
2、修改/usr/local/tomcat/webapps/cas/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml
将cookieSecure
置为false
31 p:cookieSecure="false"
3、修改/usr/local/tomcat/webapps/cas/WEB-INF/spring-configuration/warnCookieGenerator.xml
同样将cookieSecure
置为false
32 p:cookieSecure="false"
重启tomcat
重启完成后访问http://ip:port/cas/login
在usr/local/tomcat/webapps/cas/WEB-INF/deployerConfigContext.xml
中有默认用户名密码
username | password |
---|---|
casuser | Mellon |
109 <property name="users">
110 <map>
111 <entry key="casuser" value="Mellon"/>
112 </map>
113 </property>
使用默认用户名密码登录成功效果如下
退出登录访问/cas/logout
即可