Skip to Content

How to install OpenLDAP and phpLDAPadmin on ubuntu?

Install OpenLDAP and LDAP Admin on Ubuntu16

Make sure to set your system hostname and add it to file  /etc/hosts.  Replace with your hostname or valid domain name.

[email protected]:~# hostnamectl set-hostname
[email protected]:~#   vi /etc/hosts

 1) Install OpenLDAP packages

[email protected]:~#  apt update 

[email protected]:~#  apt -y install slapd ldap-utils

During the installation, you'll be prompted to set the LDAP admin password. Provide your desired password and press enter.
Confirm the password and continue the installation by pressing OK.
You can confirm that your installation was successful by using the command " slapcat ". It is used to fetch the SLAPD data content.

[email protected]:~# slapcat
dn: dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: com
dc: com
structuralObjectClass: organization
entryUUID: 5eeea770-459c-103b-9cad-53d18c55e0b0
creatorsName: cn=admin,dc=com
createTimestamp: 20210510052901Z
entryCSN: 20210510052901.084178Z#000000#000#000000
modifiersName: cn=admin,dc=com
modifyTimestamp: 20210510052901Z

dn: cn=admin,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9Z0V1WnUzU2M5bENGcnJxWWFoZGtLRjNKc09DbFU3V3A=
structuralObjectClass: organizationalRole
entryUUID: 5eef2bf0-459c-103b-9cae-53d18c55e0b0
creatorsName: cn=admin,dc=com
createTimestamp: 20210510052901Z
entryCSN: 20210510052901.087602Z#000000#000#000000
modifiersName: cn=admin,dc=com
modifyTimestamp: 20210510052901Z

 Add base dn for Users and groups
Create a file named basedn.ldif and add the following contents. Replace ezeelogin and com with your domain components.

[email protected]:~# vi basedn.ldif

dn: ou=people,dc=ezeelogin,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=ezeelogin,dc=com
objectClass: organizationalUnit
ou: groups


 Add the basedn file by running the following command 

[email protected]:~# ldapadd -x -D cn=admin,dc=ezeelogin,dc=com -W -f basedn.ldif
Enter LDAP Password:
adding new entry "ou=people,dc=ezeelogin,dc=com"

adding new entry "ou=groups,dc=ezeelogin,dc=com"

2) Install phpLDAPadmin on Ubuntu

Enter the following command to install LDAP and its dependencies.

[email protected]:~# apt -y install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear

Enable php*-cgi extension
Replace phpX.X with your PHP version.

[email protected]:~# a2enconf phpX.X-cgi
[email protected]:~#  service apache2 reload

 Install LDAP admin by running the following command

[email protected]:~# apt -y install phpldapadmin

To access phpLDAPadmin you've to use the following 

http://(server 's hostname or IP adress)/phpldapadmin

The following image shows the GUI of phpLDAPadmin
Click on " login" button at the top left corner of GUI to log in to the admin dashboard. 

NOTE: If you get the below error message on the dashboard, edit the  /etc/phpldapadmin/config.php file. Somewhere near line 300, you'll find the following lines, replace Example and com with your basedn to clear the error message. 


vi /etc/phpldapadmin/config.php



3) Creating groups in LDAP

Click on the create new child entry and select the Object which you want to create. 
Select  Generic: Posix Group and specify the group name in the text box, mark the checkbox if you want to add the users to the group. Finally, click on the create object tab to create the group in LDAP.

4) Create User in LDAP

Click on the create a child entry and select Generic: User Account.      Specify the username, select the GID Number from the drop-down menu, provide home directory, Password, user ID and then click on create Object to create the user.