Hướng dẫn centos install php ldap - centos cài đặt php ldap

Hướng dẫn centos install php ldap - centos cài đặt php ldap

LDAP viết tắt của Lightweight Directory Access Protocol là một giao thức dạng client-server được phát triển trên chuẩn X500 có chức năng phục vụ cho việc truy cập dịch vụ thư mục. LDAP có thể được sử dụng để lưu trữ bất kỳ loại thông tin nào và thường được sử dụng như một thành phần của hệ thống xác thực tập chung.

Mục lục

  1. Cấu hình đề nghị
  2. Cài đặt LDAP trên CentOS 7
  3. Cài đặt PHP Ldap Admin để quản lý tài khoản LDAP trên giao diện

1. Cấu hình đề nghị

Để cài đặt thành công LDAP, cấu hình đề nghị tối thiểu như sau:

  • Hệ điều hành: CentOS 7
  • RAM: 1GB
  • CPU: 1 Core
  • DISK: 15GB

2. Cài đặt LDAP trên CentOS 7

Cấu hình hostname

hostnamectl set-hostname "LDAP"
exec bash

Tắt firewalld

systemctl stop firewalld
systemctl disable firewalld

Tắt Selinux

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config

Cài đặt epel-release và cập nhật các gói phần mềm

yum install epel-release -y
yum update -y

Khởi động lại máy để lấy lại cấu hình mới nhất :

init 6

Cài đặt OpenLDAP

yum -y install openldap-servers openldap-clients

Sao chép file cấu hình và phân quyền

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown ldap. /var/lib/ldap/DB_CONFIG 

Khởi động slapd

systemctl start slapd
systemctl enable slapd

Thiết lập LDAP admin password, tạo mật khẩu

[root@ldap ~]# slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxLDAPPASS1

Thêm mới file chroot.ldif

cat > chrootpw.ldif << EOF
# Chỉ định mật khẩu được tạo ở trên cho phần "olcRootPW"
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxLDAPPASS1
EOF

Chạy lệnh sau để update thông tin từ file chroot.ldif

systemctl stop firewalld
systemctl disable firewalld
0

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

systemctl stop firewalld
systemctl disable firewalld
1

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

systemctl stop firewalld
systemctl disable firewalld
2

Thiết lập Manager Password, tạo mật khẩu :

systemctl stop firewalld
systemctl disable firewalld
3

Thêm mới file 

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
9:

systemctl stop firewalld
systemctl disable firewalld
4

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

systemctl stop firewalld
systemctl disable firewalld
5

Thiết lập Manager Password, tạo mật khẩu :

systemctl stop firewalld
systemctl disable firewalld
6

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

systemctl stop firewalld
systemctl disable firewalld
7

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

Thiết lập Manager Password, tạo mật khẩu :

systemctl stop firewalld
systemctl disable firewalld
8

Thêm mới file 

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
9:

systemctl stop firewalld
systemctl disable firewalld
9

Chạy lệnh sau để update thông tin:

Thêm file 

yum install epel-release -y
yum update -y
0:

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
0

Cập nhật thông tin của basedomain

Sau khi thực hiện xong các bước chúng ta sử dụng lệnh sau để kiểm tra các entry:

Để thêm mới một entry chúng ta cần tạo ra file ldif và update thông tin các file ldif đó và dùng 

yum install epel-release -y
yum update -y
1 để kiểm tra.

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
2

Ví dụ về thêm một entry user :

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
3

Update file 

yum install epel-release -y
yum update -y
2 để thông tin user được thêm vào cây LDAP :

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
4

3. Cài đặt PHP LDAP Admin để quản trị LDAP trên giao diện

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
5

Cài đặt httpd

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
6

Mở file

yum install epel-release -y
yum update -y
3 và sửa đổi các thông tin sau :

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
7

Để thêm mới một entry chúng ta cần tạo ra file ldif và update thông tin các file ldif đó và dùng 

yum install epel-release -y
yum update -y
1 để kiểm tra.

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
8

Ví dụ về thêm một entry user :

Kết quả

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Import các schemas:

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Thiết lập Manager Password, tạo mật khẩu :

Hướng dẫn centos install php ldap - centos cài đặt php ldap

Thêm mới file 

sudo setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
9:

Chạy lệnh sau để update thông tin: