sso学习之IAM环境搭建

  1. IAM简介

参考百科:

IAM(Identity and Access Management 的缩写),即“身份识别与访问管理”,具有单点登录、强大的认证管理、基于策略的集中式授权和审计、动态授权、企业可管理性等功能。

  1. 环境准备

2.0 首先创建新目录mkdir –p /HIAM/software,把相关安装包都拷贝过来,准备安装

2.1 配置hosts:先ifconfig查看下自己本机ip,然后写入hosts

 

 

这样主要应该是为了访问本机不用使用ip或者localhost,直接使用网址访问。

2.2 配置本地yum源

  主要目的是为了应对网络不佳的状况。

  1.  1.  待补上

2.3 安装jdk

Jdk:

 

 

    

    -i :显示组件信息。

        -v : view,visual显示安装过程。

        -h :hash安装时列出标记。

查看安装结果:

 

使用rpm –ql jdk1.8查询到安装到的目录:

 /usr/java/jdk1.8.0_171-amd64/

设置环境变量:

1). vi /etc/profile,shift+g跳到最后一行

2). 在文件最后添加

JAVA_HOME=/usr/java/jdk1.8.0_171-amd64

JRE_HOME=/usr/java/jdk1.8.0_171-amd64/jre

PATH=$JAVA_HOLME/bin:$JRE_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

export JAVA_HOME JRE_HOME PATH CLASSPATH

## PATH的配置根据利己原则,把原来的PATH写在后面,不然很有可能你安装完之后使用的java命令还是系统自带的openjdk里的,一般这种东西某些人又不想删。

3). source /etc/profile ##也可以放在在~/.bashrc以自动执行

3. 安装配置Tomcat

 Tomcat版本:9.0.8,进入相应目录执行

3.1 Tomcat

1 解压

[root@qingxin software]# tar -zxvf ./apache-tomcat-9.0.8.tar.gz

 

 

2 配置

 第一个tomcat使用默认配置,不修改。但按步骤还是设置下防火墙。配置过程遇到一点问题,记录下:

[root@qingxin conf]# service iptables save

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

[root@qingxin conf]# systemctl iptables save

Unknown operation 'iptables'.

[root@qingxin ~]# yum install iptables-services

[root@qingxin ~]# systemctl enable iptables

[root@qingxin ~]# systemctl start iptables

[root@qingxin ~]# service iptables save

 iptables: Saving firewall rules to /etc/sysconfig/iptables:[  确定  ]

[root@qingxin ~]# service iptables restart

至此,正常解决。参考:

http://blog.163.com/xavier_666/blog/static/25884000720163299503423/

3 启动tomcat

[root@qingxin bin]# ./startup.sh

4 访问

 

 

3.2 Tomcat(cas)

 简单说就是,复制一份。改改端口号避免冲突,启动两个容器。步骤:

  1. [root@qingxin software]# cp -r apache-tomcat-9.0.8 apache-tomcat-9.0.8-cas
  2. 修改server.xml

1)  <Server port="18005" shutdown="SHUTDOWN">

2)  <Connector port="18080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="18443" />

3)  <Connector port="18009" protocol="AJP/1.3" redirectPort="18443" />

3. 针对修改的端口修改防火墙

[root@qingxin conf]# /sbin/iptables -I INPUT -p tcp --dport 18080 -j ACCEPT

 [root@qingxin ~]# service iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables:[  确定  ]

[root@qingxin ~]# service iptables restart

    Redirecting to /bin/systemctl restart  iptables.service

  1. 启动

[root@qingxin bin]# ./startup.sh

  1. 访问

 

 

4 redis安装

  1. 安装gcc

[root@qingxin software]# yum install -y gcc g++ gcc-c++ make

  1. 解压redis

[root@qingxin software]# tar -xzvf redis-4.0.9.tar.gz

  1. 安装redis

1)      进入redis目录

   [root@qingxin software]# cd redis-4.0.9/

2)      编译

[root@qingxin redis-4.0.9]# make

3)      安装

[root@qingxin redis-4.0.9]# make install

4)      启动

[root@qingxin redis-4.0.9]# ./src/redis-server redis.conf &

 

 

5)      查看进程

[root@qingxin redis-4.0.9]# ps -ef|grep redis

root     13231  5775  0 10:13 pts/0    00:00:00 ./src/redis-server 127.0.0.1:6379

root     13239  5775  0 10:14 pts/0    00:00:00 grep --color=auto redis

6)      开放redis默认的6379端口

[root@qingxin redis-4.0.9]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT

[root@qingxin redis-4.0.9]# service iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables:[  确定  ]

[root@qingxin redis-4.0.9]# service iptables restart

          Redirecting to /bin/systemctl restart  iptables.service

     

5. Openldap

 5.1 关闭selinux

  临时关闭用setenforce 0,永久关闭需要编辑/etc/selinux/config, 将SELINUX=enforcing改为SELINUX=disabled,保存后退出,并重启。如果不希望重启,还希望达到这个效果,可以修改自定义启动脚本:echo “ /usr/sbin/setenfore 0” >> /etc/rc.local (/etc/rc.local文件链接到/etc/rc.d/rc.local文件),查看当前selinux状态可以用sestatus。

 

 

可以看到,setenforce 0之后,selinux由强制模式变成了宽容模式。

 

5.2 依赖包下载

 1). yum install gcc

 

 

 

2). yum install *ltdl* -y (-y yes自动选择)

 

 

5.3 安装Berkeley DB

 1). tar –zxvf db-5.2.36.tar.gz

先把安装包解压出来,结果如下

 

 

2). cd db-5.2.36/build_unix/ 进行安装前配置

执行:../dist/configure --prefix=/HIAM/software/berkeleydb-5.2.36

 

 

3). 编译make

 

 

经过2分钟左右的等待后,完成。准备下一步,安装。

4). 安装make install

结果如下:

 

 

5). 配置环境变量

vim /etc/profile

 

 

注意下,这里openldap还没安装,我们只是提前配置下,另外PATH我依旧习惯性的把原PATH写在后面。

6). 使配置文件修改生效

source /etc/profile

 

 

 

5.4 安装Openldap

 1). 解压tar –zxvf openldap-2.4.44.tgz

结果:

 

 

 2). 保证后面编译openldap时可以找到lib和include下的库

 

 

 

3). 进入openldap目录

 [root@qingxin software]# cd openldap-2.4.44/

4). 执行命令进行安装前的配置

 

[root@qingxin openldap-2.4.44]# ./configure --prefix=/HIAM/openldap-2.4.44 --enable-syslog --enable-modules --enable-debug --enable-ppolicy --with-tls CPPFLAGS=-I/HIAM/software/berkeleydb-5.2.36/include/ LDFLAGS=-L/HIAM/software/berkeleydb-5.2.36/lib/

 

 

正常完成,准备编译依赖

5). 编译依赖

make depend

 

 

6). 编译

make

 

 

完成,准备安装。

7). 安装

make install

 

 

 

8). 进入到openldap安装后目录,修改密码

 

注:这里直接粘贴{SSHA}Fds2viLvTTdNyyRzQqy4c4/LPuAZE13t作为密码即可,为了后面密文配置管理员密码。密码明文应该是123456

这里注意下,不管什么明文密文管理密码,你需要保留的是这个命令执行完成后的那一串字符:{SSHA}N3O/Xthj3ChOgMkaDdarpxp0uhDsoYT0

这个需要写到后面的slapd.conf配置文件里面去。这里躺了一趟坑,重点记录下。【ldap_bind: Invalid credentials (49】

[root@qingxin bin]# slappasswd

New password:

Re-enter new password:

{SSHA}N3O/Xthj3ChOgMkaDdarpxp0uhDsoYT0

 

修改密码想要生效应该需要重启openldap。

9). 启动openldap

 

 

10). 修改配置文件

 

 

这里注意下,密码和前面保持一致。

11). 准备初始化.ldif文件

在bin目录下创建ldif文件。

[root@qingxin bin]# touch 1.ldif

[root@qingxin bin]# vim 1.ldif

内容如下:

 

 

[root@qingxin bin]# vim 2.ldif

内容如下:

 

 

 

12). 导入ldif文件

密码是明文123456

[root@qingxin bin]# ./ldapadd -x -D "cn=Manager,dc=zqx,dc=com" -W -f 1.ldif

Enter LDAP Password:

adding new entry "dc=zqx,dc=com"

 

[root@qingxin bin]# ./ldapadd -x -D "cn=Manager,dc=zqx,dc=com" -W -f 2.ldif

Enter LDAP Password:

adding new entry "ou=people,dc=zqx,dc=com"

 

[root@qingxin bin]#

 

13). 导入slapd关于同步和密码策略的配置

  按文档类似的改一下就好了

 

14). 开放389端口供外部访问

   默认明文端口389,密文端口636

15). 导入密码策略

  按文档,类似的改下。遇到一个问题,ldap_add: Invalid syntax (21)。一直改格式都没有用,后来重启系统后终于好了,怀疑是不是有什么缓存之类的东西。

 

16). JXplorer

 

 

 

6. phpldapadmin

 6.1 安装php环境

  yum install httpd mysql-devel php-mysql php -y

 centos7直接yum install mysql-server会提示没有可用的包,需要自己手动wget获取下。

 php-mysql在centos上兼容性不好,会和php-mysqlnd冲突,暂时选择不安装php-mysql。【yum install httpd php php-bcmath php-gd php-mbstring php-xml php-ldap】

 

 

 

6.2 安装phpldapadmin

 

 1. 解压

       [root@qingxin software]# tar -zxvf phpldapadmin-1.2.3.tgz

 2. 创建html页面

       [root@qingxin software]# cp -r phpldapadmin-1.2.3 /var/www/html/

       [root@qingxin software]# cd /var/www/html/

       [root@qingxin html]# cd phpldapadmin-1.2.3/config/

       [root@qingxin config]# cp config.php.example config.php

       [root@qingxin config]# vim config.php

3. vim config.php

 

 

 

 

 

参考文档,根据自己实际的情况修改。

 

4). 关闭防火墙或暴露端口

[root@qingxin config]# service httpd restart

Redirecting to /bin/systemctl restart httpd.service

 

5). 登陆phpldapadmin

 

 http://192.168.15.142/phpldapadmin-1.2.3/htdocs/index.php

 

 

 

 

 

参考:https://www.cnblogs.com/lemon-le/p/6266921.html

https://www.cnblogs.com/yangxiaofei/p/5699187.html

https://www.zhukun.net/archives/7963

https://www.jianshu.com/p/cd6aa994dc21

http://blog.51cto.com/xiaofengfeng/1953736

 

转载于:https://www.cnblogs.com/zhuqingxin/p/9222976.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值